1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-22 07:23:21 +08:00

Merge pull request #8536 from smoogipoo/mania-column-width

Implement column width/spacing
This commit is contained in:
Dean Herbert 2020-04-01 15:51:22 +09:00 committed by GitHub
commit af408d511f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 80 additions and 25 deletions

View File

@ -0,0 +1,27 @@
// 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.
using osu.Framework.Allocation;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.UI;
namespace osu.Game.Rulesets.Mania.Tests.Skinning
{
public class TestSceneStage : ManiaSkinnableTestScene
{
[BackgroundDependencyLoader]
private void load()
{
SetContents(() =>
{
ManiaAction normalAction = ManiaAction.Key1;
ManiaAction specialAction = ManiaAction.Special1;
return new ManiaInputManager(new ManiaRuleset().RulesetInfo, 4)
{
Child = new ManiaStage(0, new StageDefinition { Columns = 4 }, ref normalAction, ref specialAction)
};
});
}
}
}

View File

@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Mania.UI
public class Column : ScrollingPlayfield, IKeyBindingHandler<ManiaAction>, IHasAccentColour
{
public const float COLUMN_WIDTH = 80;
private const float special_column_width = 70;
public const float SPECIAL_COLUMN_WIDTH = 70;
/// <summary>
/// The index of this column as part of the whole playfield.
@ -42,7 +42,6 @@ namespace osu.Game.Rulesets.Mania.UI
Index = index;
RelativeSizeAxes = Axes.Y;
Width = COLUMN_WIDTH;
Drawable background = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
{
@ -67,23 +66,9 @@ namespace osu.Game.Rulesets.Mania.UI
public override Axes RelativeSizeAxes => Axes.Y;
private ColumnType columnType;
public ColumnType ColumnType { get; set; }
public ColumnType ColumnType
{
get => columnType;
set
{
if (columnType == value)
return;
columnType = value;
Width = IsSpecial ? special_column_width : COLUMN_WIDTH;
}
}
public bool IsSpecial => columnType == ColumnType.Special;
public bool IsSpecial => ColumnType == ColumnType.Special;
public Color4 AccentColour { get; set; }

View File

@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mania.Objects.Drawables;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;
@ -93,7 +94,6 @@ namespace osu.Game.Rulesets.Mania.UI
AutoSizeAxes = Axes.X,
Direction = FillDirection.Horizontal,
Padding = new MarginPadding { Left = COLUMN_SPACING, Right = COLUMN_SPACING },
Spacing = new Vector2(COLUMN_SPACING, 0)
},
}
},
@ -150,6 +150,42 @@ namespace osu.Game.Rulesets.Mania.UI
}, true);
}
private ISkin currentSkin;
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
currentSkin = skin;
skin.SourceChanged += onSkinChanged;
onSkinChanged();
}
private void onSkinChanged()
{
foreach (var col in columnFlow)
{
if (col.Index > 0)
{
float spacing = currentSkin.GetConfig<LegacyManiaSkinConfigurationLookup, float>(
new LegacyManiaSkinConfigurationLookup(Columns.Count, LegacyManiaSkinConfigurationLookups.ColumnSpacing, col.Index - 1))
?.Value ?? COLUMN_SPACING;
col.Margin = new MarginPadding { Left = spacing };
}
float? width = currentSkin.GetConfig<LegacyManiaSkinConfigurationLookup, float>(
new LegacyManiaSkinConfigurationLookup(Columns.Count, LegacyManiaSkinConfigurationLookups.ColumnWidth, col.Index))
?.Value;
if (width == null)
// only used by default skin (legacy skins get defaults set in LegacyManiaSkinConfiguration)
col.Width = col.IsSpecial ? Column.SPECIAL_COLUMN_WIDTH : Column.COLUMN_WIDTH;
else
col.Width = width.Value;
}
}
public void AddColumn(Column c)
{
topLevelContainer.Add(c.TopLevelContainer.CreateProxy());

View File

@ -10,7 +10,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
using osuTK;
@ -62,10 +61,7 @@ namespace osu.Game.Rulesets.UI
hitObjectContainerLazy = new Lazy<HitObjectContainer>(CreateHitObjectContainer);
}
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; }
[Resolved]
[Resolved(CanBeNull = true)]
private IReadOnlyList<Mod> mods { get; set; }
[BackgroundDependencyLoader]
@ -137,7 +133,7 @@ namespace osu.Game.Rulesets.UI
{
base.Update();
if (beatmap != null)
if (mods != null)
{
foreach (var mod in mods)
{

View File

@ -19,6 +19,8 @@ namespace osu.Game.Skinning
public enum LegacyManiaSkinConfigurationLookups
{
ColumnWidth,
ColumnSpacing,
LightImage,
LeftLineWidth,
RightLineWidth,

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using JetBrains.Annotations;
@ -129,6 +130,14 @@ namespace osu.Game.Skinning
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));