mirror of
https://github.com/ppy/osu.git
synced 2025-01-08 00:02:54 +08:00
Implement column width and column spacing
This commit is contained in:
parent
aac7709640
commit
2d6d1a8cc6
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
public class Column : ScrollingPlayfield, IKeyBindingHandler<ManiaAction>, IHasAccentColour
|
public class Column : ScrollingPlayfield, IKeyBindingHandler<ManiaAction>, IHasAccentColour
|
||||||
{
|
{
|
||||||
public const float COLUMN_WIDTH = 80;
|
public const float COLUMN_WIDTH = 80;
|
||||||
private const float special_column_width = 70;
|
public const float SPECIAL_COLUMN_WIDTH = 70;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The index of this column as part of the whole playfield.
|
/// The index of this column as part of the whole playfield.
|
||||||
@ -42,7 +42,6 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
Index = index;
|
Index = index;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Width = COLUMN_WIDTH;
|
|
||||||
|
|
||||||
Drawable background = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.ColumnBackground), _ => new DefaultColumnBackground())
|
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;
|
public override Axes RelativeSizeAxes => Axes.Y;
|
||||||
|
|
||||||
private ColumnType columnType;
|
public ColumnType ColumnType { get; set; }
|
||||||
|
|
||||||
public ColumnType ColumnType
|
public bool IsSpecial => ColumnType == ColumnType.Special;
|
||||||
{
|
|
||||||
get => columnType;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (columnType == value)
|
|
||||||
return;
|
|
||||||
|
|
||||||
columnType = value;
|
|
||||||
|
|
||||||
Width = IsSpecial ? special_column_width : COLUMN_WIDTH;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsSpecial => columnType == ColumnType.Special;
|
|
||||||
|
|
||||||
public Color4 AccentColour { get; set; }
|
public Color4 AccentColour { get; set; }
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mania.Objects.Drawables;
|
|||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -93,7 +94,6 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
AutoSizeAxes = Axes.X,
|
AutoSizeAxes = Axes.X,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Padding = new MarginPadding { Left = COLUMN_SPACING, Right = COLUMN_SPACING },
|
Padding = new MarginPadding { Left = COLUMN_SPACING, Right = COLUMN_SPACING },
|
||||||
Spacing = new Vector2(COLUMN_SPACING, 0)
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -150,6 +150,41 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
}, true);
|
}, 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)
|
||||||
|
col.Width = col.IsSpecial ? Column.SPECIAL_COLUMN_WIDTH : Column.COLUMN_WIDTH;
|
||||||
|
else
|
||||||
|
col.Width = width.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void AddColumn(Column c)
|
public void AddColumn(Column c)
|
||||||
{
|
{
|
||||||
topLevelContainer.Add(c.TopLevelContainer.CreateProxy());
|
topLevelContainer.Add(c.TopLevelContainer.CreateProxy());
|
||||||
|
@ -19,6 +19,8 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
public enum LegacyManiaSkinConfigurationLookups
|
public enum LegacyManiaSkinConfigurationLookups
|
||||||
{
|
{
|
||||||
|
ColumnWidth,
|
||||||
|
ColumnSpacing,
|
||||||
LightImage,
|
LightImage,
|
||||||
LeftLineWidth,
|
LeftLineWidth,
|
||||||
RightLineWidth,
|
RightLineWidth,
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@ -129,6 +130,14 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
switch (maniaLookup.Lookup)
|
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:
|
case LegacyManiaSkinConfigurationLookups.HitPosition:
|
||||||
return SkinUtils.As<TValue>(new Bindable<float>(existing.HitPosition));
|
return SkinUtils.As<TValue>(new Bindable<float>(existing.HitPosition));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user