mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
apply mod difficulty settings during song select
This commit is contained in:
@ -8,6 +8,9 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osu.Game.Screens.Select;
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Tests.Beatmaps;
|
using osu.Game.Tests.Beatmaps;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -20,8 +23,10 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(BeatmapDetails) };
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(BeatmapDetails) };
|
||||||
|
|
||||||
|
private ModDisplay modDisplay;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuGameBase game)
|
private void load(OsuGameBase game, RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
BeatmapDetailArea detailsArea;
|
BeatmapDetailArea detailsArea;
|
||||||
Add(detailsArea = new BeatmapDetailArea
|
Add(detailsArea = new BeatmapDetailArea
|
||||||
@ -31,6 +36,16 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
Size = new Vector2(550f, 450f),
|
Size = new Vector2(550f, 450f),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Add(modDisplay = new ModDisplay
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Position = new Vector2(0, 25),
|
||||||
|
});
|
||||||
|
|
||||||
|
modDisplay.Current.BindTo(Mods);
|
||||||
|
|
||||||
AddStep("all metrics", () => detailsArea.Beatmap = new TestWorkingBeatmap(new Beatmap
|
AddStep("all metrics", () => detailsArea.Beatmap = new TestWorkingBeatmap(new Beatmap
|
||||||
{
|
{
|
||||||
BeatmapInfo =
|
BeatmapInfo =
|
||||||
@ -163,6 +178,58 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
AddStep("null beatmap", () => detailsArea.Beatmap = null);
|
AddStep("null beatmap", () => detailsArea.Beatmap = null);
|
||||||
|
|
||||||
|
AddStep("with EZ mod", () =>
|
||||||
|
{
|
||||||
|
detailsArea.Beatmap = new TestWorkingBeatmap(new Beatmap
|
||||||
|
{
|
||||||
|
BeatmapInfo =
|
||||||
|
{
|
||||||
|
Version = "Has Easy Mod",
|
||||||
|
Metadata = new BeatmapMetadata
|
||||||
|
{
|
||||||
|
Source = "osu!lazer",
|
||||||
|
Tags = "this beatmap has the easy mod enabled",
|
||||||
|
},
|
||||||
|
BaseDifficulty = new BeatmapDifficulty
|
||||||
|
{
|
||||||
|
CircleSize = 3,
|
||||||
|
DrainRate = 3,
|
||||||
|
OverallDifficulty = 3,
|
||||||
|
ApproachRate = 3,
|
||||||
|
},
|
||||||
|
StarDifficulty = 1f,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Mods.Value = new[] { rulesets.AvailableRulesets.First().CreateInstance().GetAllMods().First(m => m is ModEasy) };
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("with HR mod", () =>
|
||||||
|
{
|
||||||
|
detailsArea.Beatmap = new TestWorkingBeatmap(new Beatmap
|
||||||
|
{
|
||||||
|
BeatmapInfo =
|
||||||
|
{
|
||||||
|
Version = "Has Hard Rock Mod",
|
||||||
|
Metadata = new BeatmapMetadata
|
||||||
|
{
|
||||||
|
Source = "osu!lazer",
|
||||||
|
Tags = "this beatmap has the hard rock mod enabled",
|
||||||
|
},
|
||||||
|
BaseDifficulty = new BeatmapDifficulty
|
||||||
|
{
|
||||||
|
CircleSize = 3,
|
||||||
|
DrainRate = 3,
|
||||||
|
OverallDifficulty = 3,
|
||||||
|
ApproachRate = 3,
|
||||||
|
},
|
||||||
|
StarDifficulty = 1f,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Mods.Value = new[] { rulesets.AvailableRulesets.First().CreateInstance().GetAllMods().First(m => m is ModHardRock) };
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,21 @@ using osu.Game.Graphics.Sprites;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using System;
|
using System;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Select.Details
|
namespace osu.Game.Screens.Select.Details
|
||||||
{
|
{
|
||||||
public class AdvancedStats : Container
|
public class AdvancedStats : Container
|
||||||
{
|
{
|
||||||
|
[Resolved]
|
||||||
|
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; }
|
||||||
|
|
||||||
private readonly StatisticRow firstValue, hpDrain, accuracy, approachRate, starDifficulty;
|
private readonly StatisticRow firstValue, hpDrain, accuracy, approachRate, starDifficulty;
|
||||||
|
|
||||||
private BeatmapInfo beatmap;
|
private BeatmapInfo beatmap;
|
||||||
@ -30,22 +40,7 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
|
|
||||||
beatmap = value;
|
beatmap = value;
|
||||||
|
|
||||||
//mania specific
|
updateStatistics();
|
||||||
if ((Beatmap?.Ruleset?.ID ?? 0) == 3)
|
|
||||||
{
|
|
||||||
firstValue.Title = "Key Amount";
|
|
||||||
firstValue.Value = (int)MathF.Round(Beatmap?.BaseDifficulty?.CircleSize ?? 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
firstValue.Title = "Circle Size";
|
|
||||||
firstValue.Value = Beatmap?.BaseDifficulty?.CircleSize ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
hpDrain.Value = Beatmap?.BaseDifficulty?.DrainRate ?? 0;
|
|
||||||
accuracy.Value = Beatmap?.BaseDifficulty?.OverallDifficulty ?? 0;
|
|
||||||
approachRate.Value = Beatmap?.BaseDifficulty?.ApproachRate ?? 0;
|
|
||||||
starDifficulty.Value = (float)(Beatmap?.StarDifficulty ?? 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,12 +60,60 @@ namespace osu.Game.Screens.Select.Details
|
|||||||
starDifficulty = new StatisticRow(10, true) { Title = "Star Difficulty" },
|
starDifficulty = new StatisticRow(10, true) { Title = "Star Difficulty" },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load()
|
||||||
{
|
{
|
||||||
starDifficulty.AccentColour = colours.Yellow;
|
starDifficulty.AccentColour = colours.Yellow;
|
||||||
|
mods.ValueChanged += _ => updateStatistics();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateStatistics()
|
||||||
|
{
|
||||||
|
BeatmapInfo processed = Beatmap?.Clone();
|
||||||
|
|
||||||
|
if (processed != null && mods.Value.Any(m => m is IApplicableToDifficulty))
|
||||||
|
{
|
||||||
|
processed.BaseDifficulty = processed.BaseDifficulty.Clone();
|
||||||
|
|
||||||
|
foreach (var mod in mods.Value.OfType<IApplicableToDifficulty>())
|
||||||
|
mod.ApplyToDifficulty(processed.BaseDifficulty);
|
||||||
|
}
|
||||||
|
|
||||||
|
BeatmapDifficulty baseDifficulty = Beatmap?.BaseDifficulty;
|
||||||
|
BeatmapDifficulty moddedDifficulty = processed?.BaseDifficulty;
|
||||||
|
|
||||||
|
//mania specific
|
||||||
|
if ((processed?.Ruleset?.ID ?? 0) == 3)
|
||||||
|
{
|
||||||
|
firstValue.Title = "Key Amount";
|
||||||
|
firstValue.Value = (int)MathF.Round(moddedDifficulty?.CircleSize ?? 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
firstValue.Title = "Circle Size";
|
||||||
|
firstValue.Value = moddedDifficulty?.CircleSize ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
hpDrain.Value = moddedDifficulty?.DrainRate ?? 0;
|
||||||
|
accuracy.Value = moddedDifficulty?.OverallDifficulty ?? 0;
|
||||||
|
approachRate.Value = moddedDifficulty?.ApproachRate ?? 0;
|
||||||
|
starDifficulty.Value = (float)(processed?.StarDifficulty ?? 0);
|
||||||
|
|
||||||
|
hpDrain.AccentColour = (moddedDifficulty?.DrainRate ?? 0) == (baseDifficulty?.DrainRate ?? 0) ?
|
||||||
|
Color4.White : (moddedDifficulty?.DrainRate ?? 0) < (baseDifficulty?.DrainRate ?? 0) ?
|
||||||
|
colours.BlueLight : colours.RedLight;
|
||||||
|
accuracy.AccentColour = (moddedDifficulty?.OverallDifficulty ?? 0) == (baseDifficulty?.OverallDifficulty ?? 0) ?
|
||||||
|
Color4.White : (moddedDifficulty?.OverallDifficulty ?? 0) < (baseDifficulty?.OverallDifficulty ?? 0) ?
|
||||||
|
colours.BlueLight : colours.RedLight;
|
||||||
|
approachRate.AccentColour = (moddedDifficulty?.ApproachRate ?? 0) == (baseDifficulty?.ApproachRate ?? 0) ?
|
||||||
|
Color4.White : (moddedDifficulty?.ApproachRate ?? 0) < (baseDifficulty?.ApproachRate ?? 0) ?
|
||||||
|
colours.BlueLight : colours.RedLight;
|
||||||
|
firstValue.AccentColour = (moddedDifficulty?.CircleSize ?? 0) == (baseDifficulty?.CircleSize ?? 0) ?
|
||||||
|
Color4.White : (moddedDifficulty?.CircleSize ?? 0) < (baseDifficulty?.CircleSize ?? 0) ?
|
||||||
|
colours.BlueLight : colours.RedLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class StatisticRow : Container, IHasAccentColour
|
private class StatisticRow : Container, IHasAccentColour
|
||||||
|
Reference in New Issue
Block a user