mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
change ruleset source to avoid issues with converted beatmaps
This commit is contained in:
parent
4d592184ca
commit
8efe7528e3
@ -34,16 +34,13 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
var ruleset = CreateRuleset();
|
||||
|
||||
var r = ruleset.CreateBeatmapConverter(Beatmap.Value.Beatmap);
|
||||
|
||||
var n = r.Convert().BeatmapInfo.Ruleset.CreateInstance();
|
||||
Debug.Assert(ruleset != null);
|
||||
|
||||
scoreProcessor = new ScoreProcessor(n);
|
||||
scoreProcessor = new ScoreProcessor(ruleset);
|
||||
Child = new DependencyProvidingContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
CachedDependencies = new (Type, object)[] { (typeof(ScoreProcessor), scoreProcessor), (typeof(Ruleset), n) },
|
||||
CachedDependencies = new (Type, object)[] { (typeof(ScoreProcessor), scoreProcessor), (typeof(Ruleset), ruleset) },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
judgementTally = new JudgementTally(),
|
||||
@ -130,7 +127,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
private int hiddenCount()
|
||||
{
|
||||
var num = counter.JudgementContainer.Children.OfType<JudgementCounter>().First(child => child.Result.ResultInfo.Type == HitResult.LargeTickHit);
|
||||
var num = counter.JudgementContainer.Children.OfType<JudgementCounter>().First(child => child.Result.Type == HitResult.LargeTickHit);
|
||||
return num.Result.ResultCount.Value;
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,8 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
{
|
||||
@ -30,7 +30,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
private JudgementRollingCounter counter = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, DrawableRuleset ruleset)
|
||||
private void load(OsuColour colours, IBindable<RulesetInfo> ruleset)
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
InternalChild = flowContainer = new FillFlowContainer
|
||||
@ -45,16 +45,16 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
ResultName = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.Numeric.With(size: 8),
|
||||
Text = ruleset.Ruleset.GetDisplayNameForHitResult(Result.ResultInfo.Type)
|
||||
Text = ruleset.Value.CreateInstance().GetDisplayNameForHitResult(Result.Type)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var result = Result.ResultInfo.Type;
|
||||
var result = Result.Type;
|
||||
|
||||
if (result.IsBasic())
|
||||
{
|
||||
Colour = colours.ForHitResult(Result.ResultInfo.Type);
|
||||
Colour = colours.ForHitResult(Result.Type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
//Adding this in "load" will cause it to not load in properly after the first beatmap attempt. Or after existing and reentering.
|
||||
//Adding this in "load" will cause the component to not load in properly after the first beatmap attempt. Or after existing and reentering.
|
||||
//this does not happen in tests, or in the skin editor component preview button.
|
||||
foreach (var result in tally.Results)
|
||||
{
|
||||
@ -66,7 +66,7 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
{
|
||||
counter.Direction.Value = getFlow(direction.NewValue);
|
||||
}
|
||||
});
|
||||
}, true);
|
||||
Mode.BindValueChanged(_ => updateCounter(), true);
|
||||
ShowMax.BindValueChanged(value =>
|
||||
{
|
||||
@ -89,19 +89,19 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
switch (Mode.Value)
|
||||
{
|
||||
case DisplayMode.Simple:
|
||||
foreach (var counter in counters.Where(counter => counter.Result.ResultInfo.Type.IsBasic()))
|
||||
foreach (var counter in counters.Where(counter => counter.Result.Type.IsBasic()))
|
||||
counter.Show();
|
||||
|
||||
foreach (var counter in counters.Where(counter => !counter.Result.ResultInfo.Type.IsBasic()))
|
||||
foreach (var counter in counters.Where(counter => !counter.Result.Type.IsBasic()))
|
||||
counter.Hide();
|
||||
|
||||
break;
|
||||
|
||||
case DisplayMode.Normal:
|
||||
foreach (var counter in counters.Where(counter => !counter.Result.ResultInfo.Type.IsBonus()))
|
||||
foreach (var counter in counters.Where(counter => !counter.Result.Type.IsBonus()))
|
||||
counter.Show();
|
||||
|
||||
foreach (var counter in counters.Where(counter => counter.Result.ResultInfo.Type.IsBonus()))
|
||||
foreach (var counter in counters.Where(counter => counter.Result.Type.IsBonus()))
|
||||
counter.Hide();
|
||||
|
||||
break;
|
||||
|
@ -2,14 +2,13 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
{
|
||||
public struct JudgementCounterInfo
|
||||
{
|
||||
public (HitResult Type, LocalisableString Displayname) ResultInfo { get; set; }
|
||||
public HitResult Type { get; set; }
|
||||
|
||||
public BindableInt ResultCount { get; set; }
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
@ -20,39 +19,31 @@ namespace osu.Game.Screens.Play.HUD.JudgementCounter
|
||||
public List<JudgementCounterInfo> Results = new List<JudgementCounterInfo>();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IBindable<WorkingBeatmap> working)
|
||||
private void load(IBindable<RulesetInfo> ruleset)
|
||||
{
|
||||
foreach (var result in getRuleset(working).GetHitResults())
|
||||
foreach (var result in ruleset.Value.CreateInstance().GetHitResults())
|
||||
{
|
||||
Results.Add(new JudgementCounterInfo
|
||||
{
|
||||
ResultInfo = (result.result, result.displayName),
|
||||
Type = result.result,
|
||||
ResultCount = new BindableInt()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private Ruleset getRuleset(IBindable<WorkingBeatmap> working)
|
||||
{
|
||||
var ruleset = working.Value.BeatmapInfo.Ruleset.CreateInstance();
|
||||
var converter = ruleset.RulesetInfo.CreateInstance().CreateBeatmapConverter(working.Value.Beatmap);
|
||||
|
||||
return converter.CanConvert() ? converter.Convert().BeatmapInfo.Ruleset.CreateInstance() : ruleset;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
scoreProcessor.NewJudgement += judgement =>
|
||||
{
|
||||
foreach (JudgementCounterInfo result in Results.Where(result => result.ResultInfo.Type == judgement.Type))
|
||||
foreach (JudgementCounterInfo result in Results.Where(result => result.Type == judgement.Type))
|
||||
{
|
||||
result.ResultCount.Value++;
|
||||
}
|
||||
};
|
||||
scoreProcessor.JudgementReverted += judgement =>
|
||||
{
|
||||
foreach (JudgementCounterInfo result in Results.Where(result => result.ResultInfo.Type == judgement.Type))
|
||||
foreach (JudgementCounterInfo result in Results.Where(result => result.Type == judgement.Type))
|
||||
{
|
||||
result.ResultCount.Value--;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user