mirror of
https://github.com/ppy/osu.git
synced 2025-01-08 06:52:59 +08:00
Rework Content storage in ColumnFlow
This commit is contained in:
parent
58bcef934b
commit
7dba870518
@ -91,7 +91,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
{
|
{
|
||||||
foreach (var stage in stages)
|
foreach (var stage in stages)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < stage.Columns.Count; i++)
|
for (int i = 0; i < stage.Columns.Length; i++)
|
||||||
{
|
{
|
||||||
var obj = new Note { Column = i, StartTime = Time.Current + 2000 };
|
var obj = new Note { Column = i, StartTime = Time.Current + 2000 };
|
||||||
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||||||
{
|
{
|
||||||
foreach (var stage in stages)
|
foreach (var stage in stages)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < stage.Columns.Count; i++)
|
for (int i = 0; i < stage.Columns.Length; i++)
|
||||||
{
|
{
|
||||||
var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 };
|
var obj = new HoldNote { Column = i, StartTime = Time.Current + 2000, Duration = 500 };
|
||||||
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
obj.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework;
|
using osu.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -28,20 +26,21 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// All contents added to this <see cref="ColumnFlow{TContent}"/>.
|
/// All contents added to this <see cref="ColumnFlow{TContent}"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IReadOnlyList<TContent> Content => columns.Children.Select(c => c.Count == 0 ? null : (TContent)c.Child).ToList();
|
public TContent[] Content { get; }
|
||||||
|
|
||||||
private readonly FillFlowContainer<Container> columns;
|
private readonly FillFlowContainer<Container<TContent>> columns;
|
||||||
private readonly StageDefinition stageDefinition;
|
private readonly StageDefinition stageDefinition;
|
||||||
|
|
||||||
public ColumnFlow(StageDefinition stageDefinition)
|
public ColumnFlow(StageDefinition stageDefinition)
|
||||||
{
|
{
|
||||||
this.stageDefinition = stageDefinition;
|
this.stageDefinition = stageDefinition;
|
||||||
|
Content = new TContent[stageDefinition.Columns];
|
||||||
|
|
||||||
AutoSizeAxes = Axes.X;
|
AutoSizeAxes = Axes.X;
|
||||||
|
|
||||||
Masking = true;
|
Masking = true;
|
||||||
|
|
||||||
InternalChild = columns = new FillFlowContainer<Container>
|
InternalChild = columns = new FillFlowContainer<Container<TContent>>
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
AutoSizeAxes = Axes.X,
|
AutoSizeAxes = Axes.X,
|
||||||
@ -49,7 +48,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < stageDefinition.Columns; i++)
|
for (int i = 0; i < stageDefinition.Columns; i++)
|
||||||
columns.Add(new Container { RelativeSizeAxes = Axes.Y });
|
columns.Add(new Container<TContent> { RelativeSizeAxes = Axes.Y });
|
||||||
}
|
}
|
||||||
|
|
||||||
private ISkinSource currentSkin;
|
private ISkinSource currentSkin;
|
||||||
@ -102,7 +101,10 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="column">The index of the column to set the content of.</param>
|
/// <param name="column">The index of the column to set the content of.</param>
|
||||||
/// <param name="content">The content.</param>
|
/// <param name="content">The content.</param>
|
||||||
public void SetContentForColumn(int column, TContent content) => columns[column].Child = content;
|
public void SetContentForColumn(int column, TContent content)
|
||||||
|
{
|
||||||
|
Content[column] = columns[column].Child = content;
|
||||||
|
}
|
||||||
|
|
||||||
private void updateMobileSizing()
|
private void updateMobileSizing()
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
stages.Add(newStage);
|
stages.Add(newStage);
|
||||||
AddNested(newStage);
|
AddNested(newStage);
|
||||||
|
|
||||||
firstColumnIndex += newStage.Columns.Count;
|
firstColumnIndex += newStage.Columns.Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,9 +125,9 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
foreach (var stage in stages)
|
foreach (var stage in stages)
|
||||||
{
|
{
|
||||||
if (index >= stage.Columns.Count)
|
if (index >= stage.Columns.Length)
|
||||||
{
|
{
|
||||||
index -= stage.Columns.Count;
|
index -= stage.Columns.Length;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the total amount of columns across all stages in this playfield.
|
/// Retrieves the total amount of columns across all stages in this playfield.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TotalColumns => stages.Sum(s => s.Columns.Count);
|
public int TotalColumns => stages.Sum(s => s.Columns.Length);
|
||||||
|
|
||||||
private Stage getStageByColumn(int column)
|
private Stage getStageByColumn(int column)
|
||||||
{
|
{
|
||||||
@ -148,7 +148,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
foreach (var stage in stages)
|
foreach (var stage in stages)
|
||||||
{
|
{
|
||||||
sum += stage.Columns.Count;
|
sum += stage.Columns.Length;
|
||||||
if (sum > column)
|
if (sum > column)
|
||||||
return stage;
|
return stage;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// 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;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.ObjectExtensions;
|
using osu.Framework.Extensions.ObjectExtensions;
|
||||||
@ -37,7 +36,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
public const float HIT_TARGET_POSITION = 110;
|
public const float HIT_TARGET_POSITION = 110;
|
||||||
|
|
||||||
public IReadOnlyList<Column> Columns => columnFlow.Content;
|
public Column[] Columns => columnFlow.Content;
|
||||||
private readonly ColumnFlow<Column> columnFlow;
|
private readonly ColumnFlow<Column> columnFlow;
|
||||||
|
|
||||||
private readonly JudgementContainer<DrawableManiaJudgement> judgements;
|
private readonly JudgementContainer<DrawableManiaJudgement> judgements;
|
||||||
@ -184,13 +183,13 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
NewResult += OnNewResult;
|
NewResult += OnNewResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Add(HitObject hitObject) => Columns.ElementAt(((ManiaHitObject)hitObject).Column - firstColumnIndex).Add(hitObject);
|
public override void Add(HitObject hitObject) => Columns[((ManiaHitObject)hitObject).Column - firstColumnIndex].Add(hitObject);
|
||||||
|
|
||||||
public override bool Remove(HitObject hitObject) => Columns.ElementAt(((ManiaHitObject)hitObject).Column - firstColumnIndex).Remove(hitObject);
|
public override bool Remove(HitObject hitObject) => Columns[((ManiaHitObject)hitObject).Column - firstColumnIndex].Remove(hitObject);
|
||||||
|
|
||||||
public override void Add(DrawableHitObject h) => Columns.ElementAt(((ManiaHitObject)h.HitObject).Column - firstColumnIndex).Add(h);
|
public override void Add(DrawableHitObject h) => Columns[((ManiaHitObject)h.HitObject).Column - firstColumnIndex].Add(h);
|
||||||
|
|
||||||
public override bool Remove(DrawableHitObject h) => Columns.ElementAt(((ManiaHitObject)h.HitObject).Column - firstColumnIndex).Remove(h);
|
public override bool Remove(DrawableHitObject h) => Columns[((ManiaHitObject)h.HitObject).Column - firstColumnIndex].Remove(h);
|
||||||
|
|
||||||
public void Add(BarLine barLine) => base.Add(barLine);
|
public void Add(BarLine barLine) => base.Add(barLine);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user