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

changed location of BarGraph to be more generic

This commit is contained in:
Jorolf 2017-04-03 19:28:05 +02:00
parent f3946bebb4
commit 5a694e0c9d
6 changed files with 63 additions and 70 deletions

View File

@ -5,7 +5,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Testing;
using osu.Game.Database;
using osu.Game.Screens.Select.Details;
using osu.Game.Screens.Select;
using System;
using System.Linq;

View File

@ -1,15 +1,48 @@
// 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
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Screens.Select.Details
namespace osu.Game.Graphics.UserInterface
{
public class BeatmapDetailsBar : Container
public class BarGraph : FillFlowContainer<Bar>
{
public IEnumerable<float> Values
{
set
{
List<float> values = value.ToList();
List<Bar> graphBars = Children.ToList();
for (int i = 0; i < values.Count; i++)
if (graphBars.Count > i)
{
graphBars[i].Length = values[i] / values.Max();
graphBars[i].Width = 1.0f / values.Count;
}
else
Add(new Bar
{
RelativeSizeAxes = Axes.Both,
Width = 1.0f / values.Count,
Length = values[i] / values.Max(),
Direction = BarDirection.BottomToTop,
BackgroundColour = new Color4(0, 0, 0, 0),
});
}
}
}
public class Bar : Container
{
private readonly Box background;
private readonly Box bar;
@ -27,7 +60,7 @@ namespace osu.Game.Screens.Select.Details
}
set
{
length = MathHelper.Clamp(value,0,1);
length = MathHelper.Clamp(value, 0, 1);
updateBarLength();
}
}
@ -70,9 +103,9 @@ namespace osu.Game.Screens.Select.Details
}
}
public BeatmapDetailsBar()
public Bar()
{
Children = new []
Children = new[]
{
background = new Box
{

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics.Primitives;
using osu.Game.Beatmaps;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Screens.Select.Details;
using osu.Game.Screens.Select.Leaderboards;
namespace osu.Game.Screens.Select

View File

@ -12,11 +12,12 @@ using osu.Framework.Graphics.Sprites;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace osu.Game.Screens.Select.Details
namespace osu.Game.Screens.Select
{
public class BeatmapDetails : Container
{
@ -30,13 +31,13 @@ namespace osu.Game.Screens.Select.Details
private readonly DifficultyRow approachRate;
private readonly DifficultyRow stars;
private readonly BeatmapDetailsBar ratingsBar;
private readonly Bar ratingsBar;
private readonly OsuSpriteText negativeRatings;
private readonly OsuSpriteText positiveRatings;
private readonly BeatmapDetailsGraph ratingsGraph;
private readonly BarGraph ratingsGraph;
private readonly BeatmapDetailsGraph retryGraph;
private readonly BeatmapDetailsGraph failGraph;
private readonly BarGraph retryGraph;
private readonly BarGraph failGraph;
private BeatmapInfo beatmap;
public BeatmapInfo Beatmap
@ -267,7 +268,7 @@ namespace osu.Game.Screens.Select.Details
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
},
ratingsBar = new BeatmapDetailsBar
ratingsBar = new Bar
{
RelativeSizeAxes = Axes.X,
Height = 5,
@ -301,7 +302,7 @@ namespace osu.Game.Screens.Select.Details
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
},
ratingsGraph = new BeatmapDetailsGraph
ratingsGraph = new BarGraph
{
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Horizontal,
@ -316,17 +317,17 @@ namespace osu.Game.Screens.Select.Details
Text = "Points of Failure",
Font = @"Exo2.0-Medium",
},
new Container<BeatmapDetailsGraph>
new Container<BarGraph>
{
RelativeSizeAxes = Axes.X,
Size = new Vector2(1/0.6f, 50),
Children = new[]
{
retryGraph = new BeatmapDetailsGraph
retryGraph = new BarGraph
{
RelativeSizeAxes = Axes.Both,
},
failGraph = new BeatmapDetailsGraph
failGraph = new BarGraph
{
RelativeSizeAxes = Axes.Both,
},
@ -357,7 +358,7 @@ namespace osu.Game.Screens.Select.Details
private class DifficultyRow : Container
{
private readonly OsuSpriteText name;
private readonly BeatmapDetailsBar bar;
private readonly Bar bar;
private readonly OsuSpriteText valueText;
private float difficultyValue;
@ -421,7 +422,7 @@ namespace osu.Game.Screens.Select.Details
{
Font = @"Exo2.0-Medium",
},
bar = new BeatmapDetailsBar
bar = new Bar
{
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
@ -447,10 +448,10 @@ namespace osu.Game.Screens.Select.Details
}
}
private class RetryAndFailBar : Container<BeatmapDetailsBar>
private class RetryAndFailBar : Container<Bar>
{
private readonly BeatmapDetailsBar retryBar;
private readonly BeatmapDetailsBar failBar;
private readonly Bar retryBar;
private readonly Bar failBar;
public float RetryLength
{
@ -480,14 +481,14 @@ namespace osu.Game.Screens.Select.Details
{
Children = new[]
{
retryBar = new BeatmapDetailsBar
retryBar = new Bar
{
RelativeSizeAxes = Axes.Both,
Direction = BarDirection.BottomToTop,
Length = 0,
BackgroundColour = new Color4(0,0,0,0),
},
failBar = new BeatmapDetailsBar
failBar = new Bar
{
RelativeSizeAxes = Axes.Both,
Direction = BarDirection.BottomToTop,

View File

@ -1,41 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK.Graphics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Screens.Select.Details
{
public class BeatmapDetailsGraph : FillFlowContainer<BeatmapDetailsBar>
{
public IEnumerable<float> Values
{
set
{
List<float> values = value.ToList();
List<BeatmapDetailsBar> graphBars = Children.ToList();
for (int i = 0; i < values.Count; i++)
if (graphBars.Count > i)
{
graphBars[i].Length = values[i] / values.Max();
graphBars[i].Width = 1.0f / values.Count;
}
else
Add(new BeatmapDetailsBar
{
RelativeSizeAxes = Axes.Both,
Width = 1.0f / values.Count,
Length = values[i] / values.Max(),
Direction = BarDirection.BottomToTop,
BackgroundColour = new Color4(0, 0, 0, 0),
});
}
}
}
}

View File

@ -206,9 +206,8 @@
<Compile Include="Screens\Play\SkipButton.cs" />
<Compile Include="Modes\UI\StandardComboCounter.cs" />
<Compile Include="Screens\Select\BeatmapCarousel.cs" />
<Compile Include="Screens\Select\Details\BeatmapDetails.cs" />
<Compile Include="Screens\Select\Details\BeatmapDetailsBar.cs" />
<Compile Include="Screens\Select\Details\BeatmapDetailsGraph.cs" />
<Compile Include="Screens\Select\BeatmapDetails.cs" />
<Compile Include="Graphics\UserInterface\BarGraph.cs" />
<Compile Include="Screens\Select\FilterCriteria.cs" />
<Compile Include="Screens\Select\Filter\GroupMode.cs" />
<Compile Include="Screens\Select\Filter\SortMode.cs" />
@ -391,7 +390,9 @@
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Folder Include="Screens\Select\Details\" />
</ItemGroup>
<ItemGroup />
<ItemGroup />
<ItemGroup />