1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 05:32:54 +08:00

Remove StageDefinition from configuration lookups

I added this for future usage, but it turns out I can get the
definitions directly from `ManiaBeatmap`.
This commit is contained in:
Dean Herbert 2022-10-06 14:10:39 +09:00
parent 4a127f5d81
commit 0d21c0e49c
13 changed files with 30 additions and 50 deletions

View File

@ -7,7 +7,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -31,9 +30,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin, IScrollingInfo scrollingInfo, StageDefinition stageDefinition) private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
{ {
hitPosition = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.HitPosition, stageDefinition)?.Value ?? Stage.HIT_TARGET_POSITION; hitPosition = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.HitPosition)?.Value ?? Stage.HIT_TARGET_POSITION;
direction.BindTo(scrollingInfo.Direction); direction.BindTo(scrollingInfo.Direction);
direction.BindValueChanged(onDirectionChanged, true); direction.BindValueChanged(onDirectionChanged, true);

View File

@ -10,7 +10,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -31,9 +30,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin, IScrollingInfo scrollingInfo, StageDefinition stageDefinition) private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
{ {
string lightImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.LightImage, stageDefinition)?.Value string lightImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.LightImage)?.Value
?? "mania-stage-light"; ?? "mania-stage-light";
float lightPosition = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LightPosition)?.Value float lightPosition = GetColumnSkinConfig<float>(skin, LegacyManiaSkinConfigurationLookups.LightPosition)?.Value

View File

@ -9,7 +9,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -24,15 +23,15 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
private Container directionContainer; private Container directionContainer;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin, IScrollingInfo scrollingInfo, StageDefinition stageDefinition) private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
{ {
string targetImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.HitTargetImage, stageDefinition)?.Value string targetImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.HitTargetImage)?.Value
?? "mania-stage-hint"; ?? "mania-stage-hint";
bool showJudgementLine = skin.GetManiaSkinConfig<bool>(LegacyManiaSkinConfigurationLookups.ShowJudgementLine, stageDefinition)?.Value bool showJudgementLine = skin.GetManiaSkinConfig<bool>(LegacyManiaSkinConfigurationLookups.ShowJudgementLine)?.Value
?? true; ?? true;
Color4 lineColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.JudgementLineColour, stageDefinition)?.Value Color4 lineColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.JudgementLineColour)?.Value
?? Color4.White; ?? Color4.White;
InternalChild = directionContainer = new Container InternalChild = directionContainer = new Container

View File

@ -42,6 +42,6 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
} }
protected IBindable<T> GetColumnSkinConfig<T>(ISkin skin, LegacyManiaSkinConfigurationLookups lookup) protected IBindable<T> GetColumnSkinConfig<T>(ISkin skin, LegacyManiaSkinConfigurationLookups lookup)
=> skin.GetManiaSkinConfig<T>(lookup, stage, Column.Index); => skin.GetManiaSkinConfig<T>(lookup, Column.Index);
} }
} }

View File

@ -9,7 +9,6 @@ using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -33,9 +32,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin, StageDefinition stageDefinition) private void load(ISkinSource skin)
{ {
float? scorePosition = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.ScorePosition, stageDefinition)?.Value; float? scorePosition = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.ScorePosition)?.Value;
if (scorePosition != null) if (scorePosition != null)
scorePosition -= Stage.HIT_TARGET_POSITION + 150; scorePosition -= Stage.HIT_TARGET_POSITION + 150;

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -36,9 +35,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin, IScrollingInfo scrollingInfo, StageDefinition stageDefinition) private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
{ {
minimumColumnWidth = skin.GetConfig<ManiaSkinConfigurationLookup, float>(new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.MinimumColumnWidth, stageDefinition))?.Value; minimumColumnWidth = skin.GetConfig<ManiaSkinConfigurationLookup, float>(new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.MinimumColumnWidth))?.Value;
InternalChild = directionContainer = new Container InternalChild = directionContainer = new Container
{ {

View File

@ -30,10 +30,10 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin, StageDefinition stageDefinition) private void load(ISkinSource skin, StageDefinition stageDefinition)
{ {
string leftImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.LeftStageImage, stageDefinition)?.Value string leftImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.LeftStageImage)?.Value
?? "mania-stage-left"; ?? "mania-stage-left";
string rightImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.RightStageImage, stageDefinition)?.Value string rightImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.RightStageImage)?.Value
?? "mania-stage-right"; ?? "mania-stage-right";
InternalChildren = new[] InternalChildren = new[]
@ -91,16 +91,16 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin, StageDefinition stageDefinition) private void load(ISkinSource skin)
{ {
float leftLineWidth = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.LeftLineWidth, stageDefinition, columnIndex)?.Value ?? 1; float leftLineWidth = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.LeftLineWidth, columnIndex)?.Value ?? 1;
float rightLineWidth = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.RightLineWidth, stageDefinition, columnIndex)?.Value ?? 1; float rightLineWidth = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.RightLineWidth, columnIndex)?.Value ?? 1;
bool hasLeftLine = leftLineWidth > 0; bool hasLeftLine = leftLineWidth > 0;
bool hasRightLine = (rightLineWidth > 0 && skin.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value >= 2.4m) || isLastColumn; bool hasRightLine = (rightLineWidth > 0 && skin.GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version)?.Value >= 2.4m) || isLastColumn;
Color4 lineColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.ColumnLineColour, stageDefinition, columnIndex)?.Value ?? Color4.White; Color4 lineColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.ColumnLineColour, columnIndex)?.Value ?? Color4.White;
Color4 backgroundColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.ColumnBackgroundColour, stageDefinition, columnIndex)?.Value ?? Color4.Black; Color4 backgroundColour = skin.GetManiaSkinConfig<Color4>(LegacyManiaSkinConfigurationLookups.ColumnBackgroundColour, columnIndex)?.Value ?? Color4.Black;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {

View File

@ -7,7 +7,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -26,9 +25,9 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(ISkinSource skin, IScrollingInfo scrollingInfo, StageDefinition stageDefinition) private void load(ISkinSource skin, IScrollingInfo scrollingInfo)
{ {
string bottomImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.BottomStageImage, stageDefinition)?.Value string bottomImage = skin.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.BottomStageImage)?.Value
?? "mania-stage-bottom"; ?? "mania-stage-bottom";
sprite = skin.GetAnimation(bottomImage, true, true)?.With(d => sprite = skin.GetAnimation(bottomImage, true, true)?.With(d =>

View File

@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
isLegacySkin = new Lazy<bool>(() => GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version) != null); isLegacySkin = new Lazy<bool>(() => GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version) != null);
hasKeyTexture = new Lazy<bool>(() => hasKeyTexture = new Lazy<bool>(() =>
{ {
string keyImage = this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, new StageDefinition(1), 0)?.Value ?? "mania-key1"; string keyImage = this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, 0)?.Value ?? "mania-key1";
return this.GetAnimation(keyImage, true, true) != null; return this.GetAnimation(keyImage, true, true) != null;
}); });
} }
@ -132,7 +132,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
if (!hit_result_mapping.ContainsKey(result)) if (!hit_result_mapping.ContainsKey(result))
return null; return null;
string filename = this.GetManiaSkinConfig<string>(hit_result_mapping[result], new StageDefinition(1))?.Value string filename = this.GetManiaSkinConfig<string>(hit_result_mapping[result])?.Value
?? default_hit_result_skin_filenames[result]; ?? default_hit_result_skin_filenames[result];
var animation = this.GetAnimation(filename, true, true); var animation = this.GetAnimation(filename, true, true);

View File

@ -4,7 +4,6 @@
#nullable disable #nullable disable
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Skinning; using osu.Game.Skinning;
namespace osu.Game.Rulesets.Mania.Skinning namespace osu.Game.Rulesets.Mania.Skinning
@ -16,10 +15,9 @@ namespace osu.Game.Rulesets.Mania.Skinning
/// </summary> /// </summary>
/// <param name="skin">The skin from which configuration is retrieved.</param> /// <param name="skin">The skin from which configuration is retrieved.</param>
/// <param name="lookup">The value to retrieve.</param> /// <param name="lookup">The value to retrieve.</param>
/// <param name="stageDefinition">The stage definition.</param>
/// <param name="columnIndex">If not null, denotes the index of the column to which the entry applies.</param> /// <param name="columnIndex">If not null, denotes the index of the column to which the entry applies.</param>
public static IBindable<T> GetManiaSkinConfig<T>(this ISkin skin, LegacyManiaSkinConfigurationLookups lookup, StageDefinition stageDefinition, int? columnIndex = null) public static IBindable<T> GetManiaSkinConfig<T>(this ISkin skin, LegacyManiaSkinConfigurationLookups lookup, int? columnIndex = null)
=> skin.GetConfig<ManiaSkinConfigurationLookup, T>( => skin.GetConfig<ManiaSkinConfigurationLookup, T>(
new ManiaSkinConfigurationLookup(lookup, stageDefinition, columnIndex)); new ManiaSkinConfigurationLookup(lookup, columnIndex));
} }
} }

View File

@ -3,7 +3,6 @@
#nullable disable #nullable disable
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -16,11 +15,6 @@ namespace osu.Game.Rulesets.Mania.Skinning
/// </summary> /// </summary>
public readonly LegacyManiaSkinConfigurationLookups Lookup; public readonly LegacyManiaSkinConfigurationLookups Lookup;
/// <summary>
/// The stage containing the component which is performing this lookup.
/// </summary>
public readonly StageDefinition StageDefinition;
/// <summary> /// <summary>
/// The intended <see cref="Column"/> index for the configuration. /// The intended <see cref="Column"/> index for the configuration.
/// May be null if the configuration does not apply to a <see cref="Column"/>. /// May be null if the configuration does not apply to a <see cref="Column"/>.
@ -31,12 +25,10 @@ namespace osu.Game.Rulesets.Mania.Skinning
/// Creates a new <see cref="ManiaSkinConfigurationLookup"/>. /// Creates a new <see cref="ManiaSkinConfigurationLookup"/>.
/// </summary> /// </summary>
/// <param name="lookup">The lookup value.</param> /// <param name="lookup">The lookup value.</param>
/// <param name="stageDefinition">The stage definition.</param>
/// <param name="columnIndex">The intended <see cref="Column"/> index for the configuration. May be null if the configuration does not apply to a <see cref="Column"/>.</param> /// <param name="columnIndex">The intended <see cref="Column"/> index for the configuration. May be null if the configuration does not apply to a <see cref="Column"/>.</param>
public ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups lookup, StageDefinition stageDefinition, int? columnIndex = null) public ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups lookup, int? columnIndex = null)
{ {
Lookup = lookup; Lookup = lookup;
StageDefinition = stageDefinition;
ColumnIndex = columnIndex; ColumnIndex = columnIndex;
} }
} }

View File

@ -65,14 +65,14 @@ namespace osu.Game.Rulesets.Mania.UI
if (i > 0) if (i > 0)
{ {
float spacing = currentSkin.GetConfig<ManiaSkinConfigurationLookup, float>( float spacing = currentSkin.GetConfig<ManiaSkinConfigurationLookup, float>(
new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.ColumnSpacing, stageDefinition, i - 1)) new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.ColumnSpacing, i - 1))
?.Value ?? Stage.COLUMN_SPACING; ?.Value ?? Stage.COLUMN_SPACING;
columns[i].Margin = new MarginPadding { Left = spacing }; columns[i].Margin = new MarginPadding { Left = spacing };
} }
float? width = currentSkin.GetConfig<ManiaSkinConfigurationLookup, float>( float? width = currentSkin.GetConfig<ManiaSkinConfigurationLookup, float>(
new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.ColumnWidth, stageDefinition, i)) new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.ColumnWidth, i))
?.Value; ?.Value;
if (width == null) if (width == null)

View File

@ -7,7 +7,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Skinning; using osu.Game.Rulesets.Mania.Skinning;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
@ -20,9 +19,6 @@ namespace osu.Game.Rulesets.Mania.UI.Components
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>(); protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
public readonly HitObjectContainer HitObjectContainer; public readonly HitObjectContainer HitObjectContainer;
[Resolved]
private StageDefinition stageDefinition { get; set; }
public HitObjectArea(HitObjectContainer hitObjectContainer) public HitObjectArea(HitObjectContainer hitObjectContainer)
{ {
InternalChild = new Container InternalChild = new Container
@ -53,7 +49,7 @@ namespace osu.Game.Rulesets.Mania.UI.Components
protected virtual void UpdateHitPosition() protected virtual void UpdateHitPosition()
{ {
float hitPosition = CurrentSkin.GetConfig<ManiaSkinConfigurationLookup, float>( float hitPosition = CurrentSkin.GetConfig<ManiaSkinConfigurationLookup, float>(
new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.HitPosition, stageDefinition))?.Value new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.HitPosition))?.Value
?? Stage.HIT_TARGET_POSITION; ?? Stage.HIT_TARGET_POSITION;
Padding = Direction.Value == ScrollingDirection.Up Padding = Direction.Value == ScrollingDirection.Up