1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 21:42:56 +08:00

tidy up code

This commit is contained in:
mcendu 2020-06-13 11:31:34 +08:00
parent a42bfcb5ab
commit aa476835e7
2 changed files with 24 additions and 22 deletions

View File

@ -17,17 +17,19 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
{ {
public TestSceneDrawableJudgement() public TestSceneDrawableJudgement()
{ {
var HitWindows = new ManiaHitWindows(); var hitWindows = new ManiaHitWindows();
foreach (HitResult result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Skip(1)) foreach (HitResult result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Skip(1))
{ {
if (HitWindows.IsHitResultAllowed(result)) if (hitWindows.IsHitResultAllowed(result))
{
AddStep("Show " + result.GetDescription(), () => SetContents(() => AddStep("Show " + result.GetDescription(), () => SetContents(() =>
new DrawableManiaJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null) new DrawableManiaJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
})); }));
}
} }
} }
} }

View File

@ -24,31 +24,31 @@ namespace osu.Game.Rulesets.Mania.Skinning
/// Mapping of <see cref="HitResult"/> to ther corresponding /// Mapping of <see cref="HitResult"/> to ther corresponding
/// <see cref="LegacyManiaSkinConfigurationLookups"/> value. /// <see cref="LegacyManiaSkinConfigurationLookups"/> value.
/// </summary> /// </summary>
private static readonly IReadOnlyDictionary<HitResult, LegacyManiaSkinConfigurationLookups> componentMapping private static readonly IReadOnlyDictionary<HitResult, LegacyManiaSkinConfigurationLookups> hitresult_mapping
= new Dictionary<HitResult, LegacyManiaSkinConfigurationLookups> = new Dictionary<HitResult, LegacyManiaSkinConfigurationLookups>
{ {
{ HitResult.Perfect, LegacyManiaSkinConfigurationLookups.Hit300g }, { HitResult.Perfect, LegacyManiaSkinConfigurationLookups.Hit300g },
{ HitResult.Great, LegacyManiaSkinConfigurationLookups.Hit300 }, { HitResult.Great, LegacyManiaSkinConfigurationLookups.Hit300 },
{ HitResult.Good, LegacyManiaSkinConfigurationLookups.Hit200 }, { HitResult.Good, LegacyManiaSkinConfigurationLookups.Hit200 },
{ HitResult.Ok, LegacyManiaSkinConfigurationLookups.Hit100 }, { HitResult.Ok, LegacyManiaSkinConfigurationLookups.Hit100 },
{ HitResult.Meh, LegacyManiaSkinConfigurationLookups.Hit50 }, { HitResult.Meh, LegacyManiaSkinConfigurationLookups.Hit50 },
{ HitResult.Miss, LegacyManiaSkinConfigurationLookups.Hit0 } { HitResult.Miss, LegacyManiaSkinConfigurationLookups.Hit0 }
}; };
/// <summary> /// <summary>
/// Mapping of <see cref="HitResult"/> to their corresponding /// Mapping of <see cref="HitResult"/> to their corresponding
/// default filenames. /// default filenames.
/// </summary> /// </summary>
private static readonly IReadOnlyDictionary<HitResult, string> defaultName private static readonly IReadOnlyDictionary<HitResult, string> default_hitresult_skin_filenames
= new Dictionary<HitResult, string> = new Dictionary<HitResult, string>
{ {
{ HitResult.Perfect, "mania-hit300g" }, { HitResult.Perfect, "mania-hit300g" },
{ HitResult.Great, "mania-hit300" }, { HitResult.Great, "mania-hit300" },
{ HitResult.Good, "mania-hit200" }, { HitResult.Good, "mania-hit200" },
{ HitResult.Ok, "mania-hit100" }, { HitResult.Ok, "mania-hit100" },
{ HitResult.Meh, "mania-hit50" }, { HitResult.Meh, "mania-hit50" },
{ HitResult.Miss, "mania-hit0" } { HitResult.Miss, "mania-hit0" }
}; };
private Lazy<bool> isLegacySkin; private Lazy<bool> isLegacySkin;
@ -129,8 +129,8 @@ namespace osu.Game.Rulesets.Mania.Skinning
private Drawable getResult(HitResult result) private Drawable getResult(HitResult result)
{ {
string image = GetConfig<ManiaSkinConfigurationLookup, string>( string image = GetConfig<ManiaSkinConfigurationLookup, string>(
new ManiaSkinConfigurationLookup(componentMapping[result]) new ManiaSkinConfigurationLookup(hitresult_mapping[result])
)?.Value ?? defaultName[result]; )?.Value ?? default_hitresult_skin_filenames[result];
return this.GetAnimation(image, true, true); return this.GetAnimation(image, true, true);
} }