mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 23:22:55 +08:00
Added difficulty container
This commit is contained in:
parent
d8724e5e3e
commit
775fd63d0f
@ -1,4 +1,7 @@
|
||||
using osu.Framework.Graphics;
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Screens.Testing;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Screens.Select;
|
||||
@ -20,10 +23,22 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
Add(new Details
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Metadata = new BeatmapMetadata
|
||||
Beatmap = new BeatmapInfo
|
||||
{
|
||||
Source = "Some guy",
|
||||
Tags = "beatmap metadata example with a very very long list of tags and not much creativity",
|
||||
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,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ namespace osu.Game.Screens.Select
|
||||
Details = new Details
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(5),
|
||||
},
|
||||
Leaderboard = new Leaderboard
|
||||
{
|
||||
@ -121,8 +122,8 @@ namespace osu.Game.Screens.Select
|
||||
if (!IsLoaded) return;
|
||||
|
||||
if (api == null || beatmap?.BeatmapInfo == null) return;
|
||||
|
||||
Details.Metadata = beatmap.Beatmap.Metadata;
|
||||
|
||||
Details.Beatmap = beatmap.Beatmap.BeatmapInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,46 +1,72 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Database;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
public class Details : Container
|
||||
{
|
||||
private FillFlowContainer metadataContainer;
|
||||
private SpriteText description;
|
||||
private SpriteText source;
|
||||
private FillFlowContainer<SpriteText> tags;
|
||||
private BeatmapMetadata metadata;
|
||||
public BeatmapMetadata Metadata
|
||||
|
||||
private DifficultyRow circleSize;
|
||||
private DifficultyRow drainRate;
|
||||
private DifficultyRow approachRate;
|
||||
private DifficultyRow overallDifficulty;
|
||||
private DifficultyRow stars;
|
||||
|
||||
private BeatmapInfo beatmap;
|
||||
public BeatmapInfo Beatmap
|
||||
{
|
||||
get
|
||||
{
|
||||
return metadata;
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (metadata == value) return;
|
||||
metadata = value;
|
||||
source.Text = metadata.Source;
|
||||
tags.Children = metadata.Tags.Split(' ').ToList().Select(text => new SpriteText { Text = text });
|
||||
if (beatmap == value) return;
|
||||
beatmap = value;
|
||||
description.Text = beatmap.Version;
|
||||
source.Text = beatmap.Metadata.Source;
|
||||
tags.Children = beatmap.Metadata.Tags.Split(' ').Select(text => new SpriteText
|
||||
{
|
||||
Text = text,
|
||||
TextSize = 14,
|
||||
Font = "Exo2.0-Medium",
|
||||
});
|
||||
|
||||
circleSize.Value = beatmap.Difficulty.CircleSize;
|
||||
drainRate.Value = beatmap.Difficulty.DrainRate;
|
||||
approachRate.Value = beatmap.Difficulty.ApproachRate;
|
||||
overallDifficulty.Value = beatmap.Difficulty.OverallDifficulty;
|
||||
stars.Value = (float) beatmap.StarDifficulty;
|
||||
}
|
||||
}
|
||||
|
||||
public Details()
|
||||
{
|
||||
Children = new[]
|
||||
Children = new Drawable[]
|
||||
{
|
||||
metadataContainer = new FillFlowContainer()
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f,
|
||||
},
|
||||
new FillFlowContainer()
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
@ -48,22 +74,39 @@ namespace osu.Game.Screens.Select
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Width = 0.4f,
|
||||
Direction = FillDirection.Vertical,
|
||||
Padding = new MarginPadding(5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SpriteText
|
||||
{
|
||||
Text = "Description",
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
description = new SpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Medium",
|
||||
Direction = FillDirection.Full,
|
||||
},
|
||||
description = new SpriteText(),
|
||||
new SpriteText
|
||||
{
|
||||
Text = "Source",
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Margin = new MarginPadding { Top = 20 },
|
||||
},
|
||||
source = new SpriteText(),
|
||||
source = new SpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Medium",
|
||||
Direction = FillDirection.Full,
|
||||
},
|
||||
new SpriteText
|
||||
{
|
||||
Text = "Tags",
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Margin = new MarginPadding { Top = 20 },
|
||||
},
|
||||
tags = new FillFlowContainer<SpriteText>
|
||||
@ -72,7 +115,65 @@ namespace osu.Game.Screens.Select
|
||||
Spacing = new Vector2(3,0),
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Width = 0.6f,
|
||||
Padding = new MarginPadding(5) { Top = 0 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f,
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0,10),
|
||||
Padding = new MarginPadding(7),
|
||||
Children = new []
|
||||
{
|
||||
circleSize = new DifficultyRow
|
||||
{
|
||||
DifficultyName = "Circle Size",
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
MaxValue = 7,
|
||||
},
|
||||
drainRate = new DifficultyRow
|
||||
{
|
||||
DifficultyName = "HP Drain",
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
approachRate = new DifficultyRow
|
||||
{
|
||||
DifficultyName = "Accuracy",
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
overallDifficulty = new DifficultyRow
|
||||
{
|
||||
DifficultyName = "Limit Break",
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
stars = new DifficultyRow
|
||||
{
|
||||
DifficultyName = "Star Difficulty",
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -81,7 +182,103 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
description.Colour = colour.GrayB;
|
||||
source.Colour = colour.GrayB;
|
||||
tags.Colour = colour.Yellow;
|
||||
tags.Colour = colour.YellowLight;
|
||||
stars.BarColour = colour.YellowLight;
|
||||
}
|
||||
|
||||
private class DifficultyRow : Container
|
||||
{
|
||||
private SpriteText name;
|
||||
private DetailsBar bar;
|
||||
private SpriteText valueText;
|
||||
|
||||
private float difficultyValue;
|
||||
public float Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return difficultyValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
difficultyValue = value;
|
||||
bar.Value = value/maxValue;
|
||||
valueText.Text = value.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private float maxValue = 10;
|
||||
public float MaxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return maxValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
maxValue = value;
|
||||
bar.Value = Value/value;
|
||||
}
|
||||
}
|
||||
|
||||
public string DifficultyName
|
||||
{
|
||||
get
|
||||
{
|
||||
return name.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
name.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public SRGBColour BarColour
|
||||
{
|
||||
get
|
||||
{
|
||||
return bar.BarColour;
|
||||
}
|
||||
set
|
||||
{
|
||||
bar.BarColour = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DifficultyRow()
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
name = new SpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Medium",
|
||||
},
|
||||
bar = new DetailsBar
|
||||
{
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = new Vector2(1, 0.35f),
|
||||
Padding = new MarginPadding { Left = 100, Right = 25 },
|
||||
},
|
||||
valueText = new SpriteText
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Medium",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colour)
|
||||
{
|
||||
name.Colour = colour.GrayB;
|
||||
bar.BackgroundColour = colour.Gray7;
|
||||
valueText.Colour = colour.GrayB;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
68
osu.Game/Screens/Select/DetailsBar.cs
Normal file
68
osu.Game/Screens/Select/DetailsBar.cs
Normal file
@ -0,0 +1,68 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
class DetailsBar : Container
|
||||
{
|
||||
private Box background;
|
||||
private Box bar;
|
||||
|
||||
public float Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return bar.Width;
|
||||
}
|
||||
set
|
||||
{
|
||||
bar.ResizeTo(new Vector2(value, 1), 200);
|
||||
}
|
||||
}
|
||||
|
||||
public SRGBColour BackgroundColour
|
||||
{
|
||||
get
|
||||
{
|
||||
return background.Colour;
|
||||
}
|
||||
set
|
||||
{
|
||||
background.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
public SRGBColour BarColour
|
||||
{
|
||||
get
|
||||
{
|
||||
return bar.Colour;
|
||||
}
|
||||
set
|
||||
{
|
||||
bar.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DetailsBar()
|
||||
{
|
||||
Children = new []
|
||||
{
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
bar = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -202,6 +202,7 @@
|
||||
<Compile Include="Modes\UI\StandardComboCounter.cs" />
|
||||
<Compile Include="Screens\Select\BeatmapCarousel.cs" />
|
||||
<Compile Include="Screens\Select\Details.cs" />
|
||||
<Compile Include="Screens\Select\DetailsBar.cs" />
|
||||
<Compile Include="Screens\Select\FilterCriteria.cs" />
|
||||
<Compile Include="Screens\Select\Filter\GroupMode.cs" />
|
||||
<Compile Include="Screens\Select\Filter\SortMode.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user