mirror of
https://github.com/osukey/osukey.git
synced 2025-05-25 23:47:30 +09:00
Merge pull request #8535 from mcendu/mania-existence-check
Add check to detect whether mania is skinned
This commit is contained in:
commit
e862ca23ad
@ -18,6 +18,12 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
|
|
||||||
private Lazy<bool> isLegacySkin;
|
private Lazy<bool> isLegacySkin;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether texture for the keys exists.
|
||||||
|
/// Used to determine if the mania ruleset is skinned.
|
||||||
|
/// </summary>
|
||||||
|
private Lazy<bool> hasKeyTexture;
|
||||||
|
|
||||||
public ManiaLegacySkinTransformer(ISkinSource source)
|
public ManiaLegacySkinTransformer(ISkinSource source)
|
||||||
{
|
{
|
||||||
this.source = source;
|
this.source = source;
|
||||||
@ -29,6 +35,10 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
private void sourceChanged()
|
private void sourceChanged()
|
||||||
{
|
{
|
||||||
isLegacySkin = new Lazy<bool>(() => source.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null);
|
isLegacySkin = new Lazy<bool>(() => source.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null);
|
||||||
|
hasKeyTexture = new Lazy<bool>(() => source.GetAnimation(
|
||||||
|
source.GetConfig<LegacyManiaSkinConfigurationLookup, string>(
|
||||||
|
new LegacyManiaSkinConfigurationLookup(4, LegacyManiaSkinConfigurationLookups.KeyImage, 0))?.Value
|
||||||
|
?? "mania-key1", true, true) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable GetDrawableComponent(ISkinComponent component)
|
public Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
@ -39,7 +49,7 @@ namespace osu.Game.Rulesets.Mania.Skinning
|
|||||||
return getResult(resultComponent);
|
return getResult(resultComponent);
|
||||||
|
|
||||||
case ManiaSkinComponent maniaComponent:
|
case ManiaSkinComponent maniaComponent:
|
||||||
if (!isLegacySkin.Value)
|
if (!isLegacySkin.Value || !hasKeyTexture.Value)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
switch (maniaComponent.Component)
|
switch (maniaComponent.Component)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -27,7 +28,13 @@ namespace osu.Game.Skinning
|
|||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
protected IResourceStore<SampleChannel> Samples;
|
protected IResourceStore<SampleChannel> Samples;
|
||||||
|
|
||||||
protected virtual bool AllowManiaSkin => true;
|
/// <summary>
|
||||||
|
/// Whether texture for the keys exists.
|
||||||
|
/// Used to determine if the mania ruleset is skinned.
|
||||||
|
/// </summary>
|
||||||
|
private readonly Lazy<bool> hasKeyTexture;
|
||||||
|
|
||||||
|
protected virtual bool AllowManiaSkin => hasKeyTexture.Value;
|
||||||
|
|
||||||
public new LegacySkinConfiguration Configuration
|
public new LegacySkinConfiguration Configuration
|
||||||
{
|
{
|
||||||
@ -77,6 +84,10 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
(storage as ResourceStore<byte[]>)?.AddExtension("ogg");
|
(storage as ResourceStore<byte[]>)?.AddExtension("ogg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: this shouldn't really be duplicated here (from ManiaLegacySkinTransformer). we need to come up with a better solution.
|
||||||
|
hasKeyTexture = new Lazy<bool>(() => this.GetAnimation(
|
||||||
|
lookupForMania<string>(new LegacyManiaSkinConfigurationLookup(4, LegacyManiaSkinConfigurationLookups.KeyImage, 0))?.Value ?? "mania-key1", true, true) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
@ -125,28 +136,9 @@ namespace osu.Game.Skinning
|
|||||||
if (!AllowManiaSkin)
|
if (!AllowManiaSkin)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (!maniaConfigurations.TryGetValue(maniaLookup.Keys, out var existing))
|
var result = lookupForMania<TValue>(maniaLookup);
|
||||||
maniaConfigurations[maniaLookup.Keys] = existing = new LegacyManiaSkinConfiguration(maniaLookup.Keys);
|
if (result != null)
|
||||||
|
return result;
|
||||||
switch (maniaLookup.Lookup)
|
|
||||||
{
|
|
||||||
case LegacyManiaSkinConfigurationLookups.ColumnWidth:
|
|
||||||
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
||||||
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnWidth[maniaLookup.TargetColumn.Value]));
|
|
||||||
|
|
||||||
case LegacyManiaSkinConfigurationLookups.ColumnSpacing:
|
|
||||||
Debug.Assert(maniaLookup.TargetColumn != null);
|
|
||||||
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnSpacing[maniaLookup.TargetColumn.Value]));
|
|
||||||
|
|
||||||
case LegacyManiaSkinConfigurationLookups.HitPosition:
|
|
||||||
return SkinUtils.As<TValue>(new Bindable<float>(existing.HitPosition));
|
|
||||||
|
|
||||||
case LegacyManiaSkinConfigurationLookups.LightPosition:
|
|
||||||
return SkinUtils.As<TValue>(new Bindable<float>(existing.LightPosition));
|
|
||||||
|
|
||||||
case LegacyManiaSkinConfigurationLookups.ShowJudgementLine:
|
|
||||||
return SkinUtils.As<TValue>(new Bindable<bool>(existing.ShowJudgementLine));
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -177,6 +169,34 @@ namespace osu.Game.Skinning
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IBindable<TValue> lookupForMania<TValue>(LegacyManiaSkinConfigurationLookup maniaLookup)
|
||||||
|
{
|
||||||
|
if (!maniaConfigurations.TryGetValue(maniaLookup.Keys, out var existing))
|
||||||
|
maniaConfigurations[maniaLookup.Keys] = existing = new LegacyManiaSkinConfiguration(maniaLookup.Keys);
|
||||||
|
|
||||||
|
switch (maniaLookup.Lookup)
|
||||||
|
{
|
||||||
|
case LegacyManiaSkinConfigurationLookups.ColumnWidth:
|
||||||
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
||||||
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnWidth[maniaLookup.TargetColumn.Value]));
|
||||||
|
|
||||||
|
case LegacyManiaSkinConfigurationLookups.ColumnSpacing:
|
||||||
|
Debug.Assert(maniaLookup.TargetColumn != null);
|
||||||
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.ColumnSpacing[maniaLookup.TargetColumn.Value]));
|
||||||
|
|
||||||
|
case LegacyManiaSkinConfigurationLookups.HitPosition:
|
||||||
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.HitPosition));
|
||||||
|
|
||||||
|
case LegacyManiaSkinConfigurationLookups.LightPosition:
|
||||||
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.LightPosition));
|
||||||
|
|
||||||
|
case LegacyManiaSkinConfigurationLookups.ShowJudgementLine:
|
||||||
|
return SkinUtils.As<TValue>(new Bindable<bool>(existing.ShowJudgementLine));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private IBindable<Color4> getCustomColour(string lookup) => Configuration.CustomColours.TryGetValue(lookup, out var col) ? new Bindable<Color4>(col) : null;
|
private IBindable<Color4> getCustomColour(string lookup) => Configuration.CustomColours.TryGetValue(lookup, out var col) ? new Bindable<Color4>(col) : null;
|
||||||
|
|
||||||
public override Drawable GetDrawableComponent(ISkinComponent component)
|
public override Drawable GetDrawableComponent(ISkinComponent component)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user