mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 17:37:23 +09:00
Make BeatmapInfoWedge display properly for converts
This commit is contained in:
parent
09c70a9362
commit
fbd7ccc03f
@ -4,9 +4,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
@ -21,6 +23,8 @@ using osu.Game.Rulesets.Objects.Types;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select
|
namespace osu.Game.Screens.Select
|
||||||
{
|
{
|
||||||
@ -28,6 +32,8 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0);
|
private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0);
|
||||||
|
|
||||||
|
private readonly IBindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
protected BufferedWedgeInfo Info;
|
protected BufferedWedgeInfo Info;
|
||||||
|
|
||||||
public BeatmapInfoWedge()
|
public BeatmapInfoWedge()
|
||||||
@ -46,6 +52,14 @@ namespace osu.Game.Screens.Select
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load([CanBeNull] OsuGame osuGame)
|
||||||
|
{
|
||||||
|
if (osuGame != null)
|
||||||
|
ruleset.BindTo(osuGame.Ruleset);
|
||||||
|
ruleset.ValueChanged += updateRuleset;
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool BlockPassThroughMouse => false;
|
protected override bool BlockPassThroughMouse => false;
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
@ -62,7 +76,17 @@ namespace osu.Game.Screens.Select
|
|||||||
this.FadeOut(500, Easing.In);
|
this.FadeOut(500, Easing.In);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private WorkingBeatmap beatmap;
|
||||||
|
|
||||||
public void UpdateBeatmap(WorkingBeatmap beatmap)
|
public void UpdateBeatmap(WorkingBeatmap beatmap)
|
||||||
|
{
|
||||||
|
this.beatmap = beatmap;
|
||||||
|
loadBeatmap();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateRuleset(RulesetInfo ruleset) => loadBeatmap();
|
||||||
|
|
||||||
|
private void loadBeatmap()
|
||||||
{
|
{
|
||||||
LoadComponentAsync(new BufferedWedgeInfo(beatmap)
|
LoadComponentAsync(new BufferedWedgeInfo(beatmap)
|
||||||
{
|
{
|
||||||
@ -90,14 +114,18 @@ namespace osu.Game.Screens.Select
|
|||||||
private UnicodeBindableString titleBinding;
|
private UnicodeBindableString titleBinding;
|
||||||
private UnicodeBindableString artistBinding;
|
private UnicodeBindableString artistBinding;
|
||||||
|
|
||||||
|
private RulesetInfo ruleset;
|
||||||
|
|
||||||
public BufferedWedgeInfo(WorkingBeatmap working)
|
public BufferedWedgeInfo(WorkingBeatmap working)
|
||||||
{
|
{
|
||||||
this.working = working;
|
this.working = working;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(LocalisationEngine localisation)
|
private void load([NotNull] LocalisationEngine localisation, [CanBeNull] OsuGame osuGame)
|
||||||
{
|
{
|
||||||
|
ruleset = osuGame?.Ruleset.Value ?? working.BeatmapInfo.Ruleset;
|
||||||
|
|
||||||
var beatmapInfo = working.BeatmapInfo;
|
var beatmapInfo = working.BeatmapInfo;
|
||||||
var metadata = beatmapInfo.Metadata ?? working.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
|
var metadata = beatmapInfo.Metadata ?? working.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
|
||||||
|
|
||||||
@ -211,7 +239,6 @@ namespace osu.Game.Screens.Select
|
|||||||
private InfoLabel[] getInfoLabels()
|
private InfoLabel[] getInfoLabels()
|
||||||
{
|
{
|
||||||
var beatmap = working.Beatmap;
|
var beatmap = working.Beatmap;
|
||||||
var info = working.BeatmapInfo;
|
|
||||||
|
|
||||||
List<InfoLabel> labels = new List<InfoLabel>();
|
List<InfoLabel> labels = new List<InfoLabel>();
|
||||||
|
|
||||||
@ -234,8 +261,20 @@ namespace osu.Game.Screens.Select
|
|||||||
Content = getBPMRange(beatmap),
|
Content = getBPMRange(beatmap),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
//get statistics for the current ruleset.
|
IBeatmap playableBeatmap;
|
||||||
labels.AddRange(working.GetPlayableBeatmap(info.Ruleset).GetStatistics().Select(s => new InfoLabel(s)));
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Try to get the beatmap with the user's ruleset
|
||||||
|
playableBeatmap = working.GetPlayableBeatmap(ruleset);
|
||||||
|
}
|
||||||
|
catch (BeatmapInvalidForRulesetException)
|
||||||
|
{
|
||||||
|
// Can't be converted to the user's ruleset, so use the beatmap's own ruleset
|
||||||
|
playableBeatmap = working.GetPlayableBeatmap(working.BeatmapInfo.Ruleset);
|
||||||
|
}
|
||||||
|
|
||||||
|
labels.AddRange(playableBeatmap.GetStatistics().Select(s => new InfoLabel(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return labels.ToArray();
|
return labels.ToArray();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user