mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Add basic display for pp in TestCasePerformancePoints
This commit is contained in:
parent
95fd323c6b
commit
38fe95d94a
13
osu.Game.Rulesets.Catch/Tests/TestCasePerformancePoints.cs
Normal file
13
osu.Game.Rulesets.Catch/Tests/TestCasePerformancePoints.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// 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.Rulesets.Catch.Tests
|
||||
{
|
||||
public class TestCasePerformancePoints : osu.Game.Tests.Visual.TestCasePerformancePoints
|
||||
{
|
||||
public TestCasePerformancePoints()
|
||||
: base(new CatchRuleset(new RulesetInfo()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -65,6 +65,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Tests\TestCaseCatcher.cs" />
|
||||
<Compile Include="Tests\TestCaseCatchStacker.cs" />
|
||||
<Compile Include="Tests\TestCasePerformancePoints.cs" />
|
||||
<Compile Include="Tests\TestCaseCatchPlayer.cs" />
|
||||
<Compile Include="UI\Catcher.cs" />
|
||||
<Compile Include="UI\CatchRulesetContainer.cs" />
|
||||
|
13
osu.Game.Rulesets.Mania/Tests/TestCasePerformancePoints.cs
Normal file
13
osu.Game.Rulesets.Mania/Tests/TestCasePerformancePoints.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// 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.Rulesets.Mania.Tests
|
||||
{
|
||||
public class TestCasePerformancePoints : osu.Game.Tests.Visual.TestCasePerformancePoints
|
||||
{
|
||||
public TestCasePerformancePoints()
|
||||
: base(new ManiaRuleset(new RulesetInfo()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -82,6 +82,7 @@
|
||||
<Compile Include="ManiaInputManager.cs" />
|
||||
<Compile Include="Tests\TestCaseManiaHitObjects.cs" />
|
||||
<Compile Include="Tests\TestCaseManiaPlayfield.cs" />
|
||||
<Compile Include="Tests\TestCasePerformancePoints.cs" />
|
||||
<Compile Include="Timing\GravityScrollingContainer.cs" />
|
||||
<Compile Include="Timing\ScrollingAlgorithm.cs" />
|
||||
<Compile Include="UI\Column.cs" />
|
||||
|
13
osu.Game.Rulesets.Osu/Tests/TestCasePerformancePoints.cs
Normal file
13
osu.Game.Rulesets.Osu/Tests/TestCasePerformancePoints.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// 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.Rulesets.Osu.Tests
|
||||
{
|
||||
public class TestCasePerformancePoints : osu.Game.Tests.Visual.TestCasePerformancePoints
|
||||
{
|
||||
public TestCasePerformancePoints()
|
||||
: base(new OsuRuleset(new RulesetInfo()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -85,6 +85,7 @@
|
||||
<Compile Include="OsuInputManager.cs" />
|
||||
<Compile Include="Replays\OsuReplayInputHandler.cs" />
|
||||
<Compile Include="Tests\TestCaseHitObjects.cs" />
|
||||
<Compile Include="Tests\TestCasePerformancePoints.cs" />
|
||||
<Compile Include="UI\Cursor\CursorTrail.cs" />
|
||||
<Compile Include="UI\Cursor\GameplayCursor.cs" />
|
||||
<Compile Include="UI\OsuSettings.cs" />
|
||||
|
13
osu.Game.Rulesets.Taiko/Tests/TestCasePerformancePoints.cs
Normal file
13
osu.Game.Rulesets.Taiko/Tests/TestCasePerformancePoints.cs
Normal file
@ -0,0 +1,13 @@
|
||||
// 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.Rulesets.Taiko.Tests
|
||||
{
|
||||
public class TestCasePerformancePoints : osu.Game.Tests.Visual.TestCasePerformancePoints
|
||||
{
|
||||
public TestCasePerformancePoints()
|
||||
: base(new TaikoRuleset(new RulesetInfo()))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -83,6 +83,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Scoring\TaikoScoreProcessor.cs" />
|
||||
<Compile Include="TaikoInputManager.cs" />
|
||||
<Compile Include="Tests\TestCasePerformancePoints.cs" />
|
||||
<Compile Include="Tests\TestCaseTaikoPlayfield.cs" />
|
||||
<Compile Include="UI\HitTarget.cs" />
|
||||
<Compile Include="UI\InputDrum.cs" />
|
||||
|
214
osu.Game/Tests/Visual/TestCasePerformancePoints.cs
Normal file
214
osu.Game/Tests/Visual/TestCasePerformancePoints.cs
Normal file
@ -0,0 +1,214 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Music;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Tests.Visual
|
||||
{
|
||||
public abstract class TestCasePerformancePoints : OsuTestCase
|
||||
{
|
||||
public TestCasePerformancePoints(Ruleset ruleset)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 300,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f,
|
||||
},
|
||||
new ScrollContainer(Direction.Vertical)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new BeatmapList(ruleset)
|
||||
}
|
||||
}
|
||||
},
|
||||
new PpDisplay(ruleset)
|
||||
};
|
||||
}
|
||||
|
||||
private class BeatmapList : CompositeDrawable
|
||||
{
|
||||
private readonly Container<BeatmapDisplay> beatmapDisplays;
|
||||
private readonly Ruleset ruleset;
|
||||
|
||||
public BeatmapList(Ruleset ruleset)
|
||||
{
|
||||
this.ruleset = ruleset;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
InternalChild = beatmapDisplays = new FillFlowContainer<BeatmapDisplay>
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 4)
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase osuGame, BeatmapManager beatmaps)
|
||||
{
|
||||
var sets = beatmaps.GetAllUsableBeatmapSets();
|
||||
var allBeatmaps = sets.SelectMany(s => s.Beatmaps).Where(b => ruleset.LegacyID < 0 || b.RulesetID == ruleset.LegacyID);
|
||||
|
||||
allBeatmaps.ForEach(b => beatmapDisplays.Add(new BeatmapDisplay(b)));
|
||||
}
|
||||
|
||||
private class BeatmapDisplay : CompositeDrawable
|
||||
{
|
||||
private readonly OsuSpriteText text;
|
||||
private readonly BeatmapInfo beatmap;
|
||||
|
||||
private BeatmapManager beatmaps;
|
||||
private OsuGameBase osuGame;
|
||||
|
||||
private bool isSelected;
|
||||
|
||||
public BeatmapDisplay(BeatmapInfo beatmap)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
InternalChild = text = new OsuSpriteText();
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
if (osuGame.Beatmap.Value.BeatmapInfo.ID == beatmap.ID)
|
||||
return false;
|
||||
|
||||
osuGame.Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap);
|
||||
isSelected = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
if (isSelected)
|
||||
return false;
|
||||
this.FadeColour(Color4.Yellow, 100);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
if (isSelected)
|
||||
return;
|
||||
this.FadeColour(Color4.White, 100);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase osuGame, BeatmapManager beatmaps)
|
||||
{
|
||||
this.osuGame = osuGame;
|
||||
this.beatmaps = beatmaps;
|
||||
|
||||
var working = beatmaps.GetWorkingBeatmap(beatmap);
|
||||
text.Text = $"{beatmap.Metadata.Artist} - {beatmap.Metadata.Title} ({beatmap.Metadata.AuthorString}) [{beatmap.Version}]";
|
||||
|
||||
osuGame.Beatmap.ValueChanged += beatmapChanged;
|
||||
}
|
||||
|
||||
private void beatmapChanged(WorkingBeatmap newBeatmap)
|
||||
{
|
||||
if (isSelected)
|
||||
this.FadeColour(Color4.White, 100);
|
||||
isSelected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PpDisplay : CompositeDrawable
|
||||
{
|
||||
private readonly Container<OsuSpriteText> strainsContainer;
|
||||
private readonly OsuSpriteText totalPp;
|
||||
|
||||
private readonly Ruleset ruleset;
|
||||
|
||||
public PpDisplay(Ruleset ruleset)
|
||||
{
|
||||
this.ruleset = ruleset;
|
||||
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
Width = 400;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.2f
|
||||
},
|
||||
totalPp = new OsuSpriteText { TextSize = 18 },
|
||||
new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Y = 26,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.2f,
|
||||
},
|
||||
strainsContainer = new FillFlowContainer<OsuSpriteText>
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase osuGame)
|
||||
{
|
||||
osuGame.Beatmap.ValueChanged += beatmapChanged;
|
||||
}
|
||||
|
||||
private void beatmapChanged(WorkingBeatmap beatmap)
|
||||
{
|
||||
var diffCalculator = ruleset.CreateDifficultyCalculator(beatmap.Beatmap);
|
||||
|
||||
var strains = new Dictionary<string, string>();
|
||||
double pp = diffCalculator.Calculate(strains);
|
||||
|
||||
totalPp.Text = $"Total PP: {pp.ToString("n2")}";
|
||||
|
||||
strainsContainer.Clear();
|
||||
foreach (var kvp in strains)
|
||||
strainsContainer.Add(new OsuSpriteText { Text = $"{kvp.Key} : {kvp.Value}" });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -775,6 +775,7 @@
|
||||
<Compile Include="Tests\Beatmaps\TestWorkingBeatmap.cs" />
|
||||
<Compile Include="Tests\Platform\TestStorage.cs" />
|
||||
<Compile Include="Tests\Visual\OsuTestCase.cs" />
|
||||
<Compile Include="Tests\Visual\TestCasePerformancePoints.cs" />
|
||||
<Compile Include="Tests\Visual\TestCasePlayer.cs" />
|
||||
<Compile Include="Users\Avatar.cs" />
|
||||
<Compile Include="Users\Country.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user