1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +08:00

Merge pull request #9264 from mcendu/mania-custom-judgement-sprite-path

Add support for custom file paths for mania hit judgement
This commit is contained in:
Dean Herbert 2020-06-13 22:03:06 +09:00 committed by GitHub
commit a8e83c5be5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 74 additions and 35 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -1,6 +1,12 @@
[General]
Version: 2.4
Version: 2.5
[Mania]
Keys: 4
ColumnLineWidth: 3,1,3,1,1
Hit0: mania/hit0
Hit50: mania/hit50
Hit100: mania/hit100
Hit200: mania/hit200
Hit300: mania/hit300
Hit300g: mania/hit300g

View File

@ -6,6 +6,7 @@ using System.Linq;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Scoring;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
@ -16,7 +17,11 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
{
public TestSceneDrawableJudgement()
{
var hitWindows = new ManiaHitWindows();
foreach (HitResult result in Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Skip(1))
{
if (hitWindows.IsHitResultAllowed(result))
{
AddStep("Show " + result.GetDescription(), () => SetContents(() =>
new DrawableManiaJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null)
@ -27,4 +32,5 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
}
}
}
}
}

View File

@ -11,6 +11,7 @@ using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Skinning;
using System.Collections.Generic;
namespace osu.Game.Rulesets.Mania.Skinning
{
@ -19,6 +20,36 @@ namespace osu.Game.Rulesets.Mania.Skinning
private readonly ISkin source;
private readonly ManiaBeatmap beatmap;
/// <summary>
/// Mapping of <see cref="HitResult"/> to their corresponding
/// <see cref="LegacyManiaSkinConfigurationLookups"/> value.
/// </summary>
private static readonly IReadOnlyDictionary<HitResult, LegacyManiaSkinConfigurationLookups> hitresult_mapping
= new Dictionary<HitResult, LegacyManiaSkinConfigurationLookups>
{
{ HitResult.Perfect, LegacyManiaSkinConfigurationLookups.Hit300g },
{ HitResult.Great, LegacyManiaSkinConfigurationLookups.Hit300 },
{ HitResult.Good, LegacyManiaSkinConfigurationLookups.Hit200 },
{ HitResult.Ok, LegacyManiaSkinConfigurationLookups.Hit100 },
{ HitResult.Meh, LegacyManiaSkinConfigurationLookups.Hit50 },
{ HitResult.Miss, LegacyManiaSkinConfigurationLookups.Hit0 }
};
/// <summary>
/// Mapping of <see cref="HitResult"/> to their corresponding
/// default filenames.
/// </summary>
private static readonly IReadOnlyDictionary<HitResult, string> default_hitresult_skin_filenames
= new Dictionary<HitResult, string>
{
{ HitResult.Perfect, "mania-hit300g" },
{ HitResult.Great, "mania-hit300" },
{ HitResult.Good, "mania-hit200" },
{ HitResult.Ok, "mania-hit100" },
{ HitResult.Meh, "mania-hit50" },
{ HitResult.Miss, "mania-hit0" }
};
private Lazy<bool> isLegacySkin;
/// <summary>
@ -50,7 +81,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
switch (component)
{
case GameplaySkinComponent<HitResult> resultComponent:
return getResult(resultComponent);
return getResult(resultComponent.Component);
case ManiaSkinComponent maniaComponent:
if (!isLegacySkin.Value || !hasKeyTexture.Value)
@ -95,30 +126,13 @@ namespace osu.Game.Rulesets.Mania.Skinning
return null;
}
private Drawable getResult(GameplaySkinComponent<HitResult> resultComponent)
private Drawable getResult(HitResult result)
{
switch (resultComponent.Component)
{
case HitResult.Miss:
return this.GetAnimation("mania-hit0", true, true);
string filename = GetConfig<ManiaSkinConfigurationLookup, string>(
new ManiaSkinConfigurationLookup(hitresult_mapping[result])
)?.Value ?? default_hitresult_skin_filenames[result];
case HitResult.Meh:
return this.GetAnimation("mania-hit50", true, true);
case HitResult.Ok:
return this.GetAnimation("mania-hit100", true, true);
case HitResult.Good:
return this.GetAnimation("mania-hit200", true, true);
case HitResult.Great:
return this.GetAnimation("mania-hit300", true, true);
case HitResult.Perfect:
return this.GetAnimation("mania-hit300g", true, true);
}
return null;
return this.GetAnimation(filename, true, true);
}
public Texture GetTexture(string componentName) => source.GetTexture(componentName);

View File

@ -43,6 +43,12 @@ namespace osu.Game.Skinning
MinimumColumnWidth,
LeftStageImage,
RightStageImage,
BottomStageImage
BottomStageImage,
Hit300g,
Hit300,
Hit200,
Hit100,
Hit50,
Hit0,
}
}

View File

@ -111,11 +111,10 @@ namespace osu.Game.Skinning
HandleColours(currentConfig, line);
break;
// Custom sprite paths
case string _ when pair.Key.StartsWith("NoteImage"):
currentConfig.ImageLookups[pair.Key] = pair.Value;
break;
case string _ when pair.Key.StartsWith("KeyImage"):
case string _ when pair.Key.StartsWith("Hit"):
currentConfig.ImageLookups[pair.Key] = pair.Value;
break;
}

View File

@ -257,6 +257,14 @@ namespace osu.Game.Skinning
case LegacyManiaSkinConfigurationLookups.RightLineWidth:
Debug.Assert(maniaLookup.TargetColumn != null);
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnLineWidth[maniaLookup.TargetColumn.Value + 1]));
case LegacyManiaSkinConfigurationLookups.Hit0:
case LegacyManiaSkinConfigurationLookups.Hit50:
case LegacyManiaSkinConfigurationLookups.Hit100:
case LegacyManiaSkinConfigurationLookups.Hit200:
case LegacyManiaSkinConfigurationLookups.Hit300:
case LegacyManiaSkinConfigurationLookups.Hit300g:
return SkinUtils.As<TValue>(getManiaImage(existing, maniaLookup.Lookup.ToString()));
}
return null;