mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:35:10 +08:00
Move column initialisation to ctor and fix remaining tests
This commit is contained in:
parent
5fe9b953a5
commit
2ae1aef0be
@ -10,6 +10,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
@ -30,6 +31,9 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
[Cached(typeof(IScrollingInfo))]
|
||||
private IScrollingInfo scrollingInfo;
|
||||
|
||||
[Cached]
|
||||
private readonly StageDefinition stage = new StageDefinition(5);
|
||||
|
||||
protected ManiaPlacementBlueprintTestScene()
|
||||
{
|
||||
scrollingInfo = ((ScrollingTestContainer)HitObjectContainer).ScrollingInfo;
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
|
||||
protected ManiaSelectionBlueprintTestScene(int columns)
|
||||
{
|
||||
var stageDefinitions = new List<StageDefinition> { new StageDefinition { Columns = columns } };
|
||||
var stageDefinitions = new List<StageDefinition> { new StageDefinition(columns) };
|
||||
base.Content.Child = scrollingTestContainer = new ScrollingTestContainer(ScrollingDirection.Up)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
private ScrollingTestContainer.TestScrollingInfo scrollingInfo = new ScrollingTestContainer.TestScrollingInfo();
|
||||
|
||||
[Cached(typeof(EditorBeatmap))]
|
||||
private EditorBeatmap editorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition())
|
||||
private EditorBeatmap editorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition(2))
|
||||
{
|
||||
BeatmapInfo =
|
||||
{
|
||||
@ -56,8 +56,8 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
{
|
||||
Playfield = new ManiaPlayfield(new List<StageDefinition>
|
||||
{
|
||||
new StageDefinition { Columns = 4 },
|
||||
new StageDefinition { Columns = 3 }
|
||||
new StageDefinition(4),
|
||||
new StageDefinition(3)
|
||||
})
|
||||
{
|
||||
Clock = new FramedClock(new StopwatchClock())
|
||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
{
|
||||
AddStep("setup compose screen", () =>
|
||||
{
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 4 })
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(4))
|
||||
{
|
||||
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
|
||||
};
|
||||
|
@ -205,7 +205,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
EditorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 })
|
||||
EditorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition(4))
|
||||
{
|
||||
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo }
|
||||
}),
|
||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
[TestCase(ManiaAction.Key8)]
|
||||
public void TestEncodeDecodeSingleStage(params ManiaAction[] actions)
|
||||
{
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 9 });
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(9));
|
||||
|
||||
var frame = new ManiaReplayFrame(0, actions);
|
||||
var legacyFrame = frame.ToLegacy(beatmap);
|
||||
@ -38,8 +38,8 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
[TestCase(ManiaAction.Key8)]
|
||||
public void TestEncodeDecodeDualStage(params ManiaAction[] actions)
|
||||
{
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 5 });
|
||||
beatmap.Stages.Add(new StageDefinition { Columns = 5 });
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(5));
|
||||
beatmap.Stages.Add(new StageDefinition(5));
|
||||
|
||||
var frame = new ManiaReplayFrame(0, actions);
|
||||
var legacyFrame = frame.ToLegacy(beatmap);
|
||||
|
@ -35,10 +35,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
}, 7)]
|
||||
public void Test(IEnumerable<bool> special, int columns)
|
||||
{
|
||||
var definition = new StageDefinition
|
||||
{
|
||||
Columns = columns
|
||||
};
|
||||
var definition = new StageDefinition(columns);
|
||||
var results = getResults(definition);
|
||||
Assert.AreEqual(special, results);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Mods
|
||||
|
||||
private static ManiaBeatmap createRawBeatmap()
|
||||
{
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 });
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(1));
|
||||
beatmap.ControlPointInfo.Add(0.0, new TimingControlPoint { BeatLength = 1000 }); // Set BPM to 60
|
||||
|
||||
// Add test hit objects
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
||||
private readonly Column column;
|
||||
|
||||
[Cached]
|
||||
private readonly StageDefinition stageDefinition = new StageDefinition { Columns = 2 };
|
||||
private readonly StageDefinition stageDefinition = new StageDefinition(5);
|
||||
|
||||
public ColumnTestContainer(int column, ManiaAction action, bool showColumn = false)
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Rulesets.UI.Scrolling.Algorithms;
|
||||
using osu.Game.Tests.Visual;
|
||||
@ -24,6 +25,9 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
||||
[Cached(Type = typeof(IScrollingInfo))]
|
||||
private readonly TestScrollingInfo scrollingInfo = new TestScrollingInfo();
|
||||
|
||||
[Cached]
|
||||
private readonly StageDefinition stage = new StageDefinition(4);
|
||||
|
||||
protected override Ruleset CreateRulesetForSkinProvider() => new ManiaRuleset();
|
||||
|
||||
protected ManiaSkinnableTestScene()
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
||||
{
|
||||
var stageDefinitions = new List<StageDefinition>
|
||||
{
|
||||
new StageDefinition { Columns = 4 },
|
||||
new StageDefinition(4),
|
||||
};
|
||||
|
||||
SetContents(_ => new ManiaPlayfield(stageDefinitions).With(s =>
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
||||
{
|
||||
stageDefinitions = new List<StageDefinition>
|
||||
{
|
||||
new StageDefinition { Columns = 2 }
|
||||
new StageDefinition(2)
|
||||
};
|
||||
|
||||
SetContents(_ => new ManiaPlayfield(stageDefinitions));
|
||||
@ -36,8 +36,8 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
||||
{
|
||||
stageDefinitions = new List<StageDefinition>
|
||||
{
|
||||
new StageDefinition { Columns = 2 },
|
||||
new StageDefinition { Columns = 2 }
|
||||
new StageDefinition(2),
|
||||
new StageDefinition(2)
|
||||
};
|
||||
|
||||
SetContents(_ => new ManiaPlayfield(stageDefinitions));
|
||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Skinning
|
||||
|
||||
return new ManiaInputManager(new ManiaRuleset().RulesetInfo, 4)
|
||||
{
|
||||
Child = new Stage(0, new StageDefinition { Columns = 4 }, ref normalAction, ref specialAction)
|
||||
Child = new Stage(0, new StageDefinition(4), ref normalAction, ref specialAction)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
// | - |
|
||||
// | |
|
||||
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 });
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(1));
|
||||
beatmap.HitObjects.Add(new Note { StartTime = 1000 });
|
||||
|
||||
var generated = new ManiaAutoGenerator(beatmap).Generate();
|
||||
@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
// | * |
|
||||
// | |
|
||||
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 });
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(1));
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 });
|
||||
|
||||
var generated = new ManiaAutoGenerator(beatmap).Generate();
|
||||
@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
// | - | - |
|
||||
// | | |
|
||||
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(2));
|
||||
beatmap.HitObjects.Add(new Note { StartTime = 1000 });
|
||||
beatmap.HitObjects.Add(new Note { StartTime = 1000, Column = 1 });
|
||||
|
||||
@ -92,7 +92,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
// | * | * |
|
||||
// | | |
|
||||
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(2));
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 });
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000, Column = 1 });
|
||||
|
||||
@ -115,7 +115,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
// | - | |
|
||||
// | | |
|
||||
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(2));
|
||||
beatmap.HitObjects.Add(new Note { StartTime = 1000 });
|
||||
beatmap.HitObjects.Add(new Note { StartTime = 2000, Column = 1 });
|
||||
|
||||
@ -142,7 +142,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
// | * | |
|
||||
// | | |
|
||||
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(2));
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 });
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 2000, Duration = 2000, Column = 1 });
|
||||
|
||||
@ -169,7 +169,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
// | * | |
|
||||
// | | |
|
||||
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 2 });
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(2));
|
||||
beatmap.HitObjects.Add(new HoldNote { StartTime = 1000, Duration = 2000 });
|
||||
beatmap.HitObjects.Add(new Note { StartTime = 3000, Column = 1 });
|
||||
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
@ -28,6 +29,9 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
[Cached(typeof(IReadOnlyList<Mod>))]
|
||||
private IReadOnlyList<Mod> mods { get; set; } = Array.Empty<Mod>();
|
||||
|
||||
[Cached]
|
||||
private readonly StageDefinition stage = new StageDefinition(1);
|
||||
|
||||
private readonly List<Column> columns = new List<Column>();
|
||||
|
||||
public TestSceneColumn()
|
||||
|
@ -4,11 +4,13 @@
|
||||
#nullable disable
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
@ -24,6 +26,9 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
|
||||
private Column column;
|
||||
|
||||
[Cached]
|
||||
private readonly StageDefinition stage = new StageDefinition(1);
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() =>
|
||||
{
|
||||
|
@ -141,7 +141,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
AddStep("load player", () =>
|
||||
{
|
||||
Beatmap.Value = CreateWorkingBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 })
|
||||
Beatmap.Value = CreateWorkingBeatmap(new ManiaBeatmap(new StageDefinition(4))
|
||||
{
|
||||
HitObjects = hitObjects,
|
||||
BeatmapInfo =
|
||||
|
@ -135,7 +135,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
var specialAction = ManiaAction.Special1;
|
||||
|
||||
var stage = new Stage(0, new StageDefinition { Columns = 2 }, ref action, ref specialAction);
|
||||
var stage = new Stage(0, new StageDefinition(2), ref action, ref specialAction);
|
||||
stages.Add(stage);
|
||||
|
||||
return new ScrollingTestContainer(direction)
|
||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
const double beat_length = 500;
|
||||
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 1 })
|
||||
var beatmap = new ManiaBeatmap(new StageDefinition(1))
|
||||
{
|
||||
HitObjects =
|
||||
{
|
||||
|
@ -93,10 +93,10 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||
|
||||
protected override Beatmap<ManiaHitObject> CreateBeatmap()
|
||||
{
|
||||
beatmap = new ManiaBeatmap(new StageDefinition { Columns = TargetColumns }, originalTargetColumns);
|
||||
beatmap = new ManiaBeatmap(new StageDefinition(TargetColumns), originalTargetColumns);
|
||||
|
||||
if (Dual)
|
||||
beatmap.Stages.Add(new StageDefinition { Columns = TargetColumns });
|
||||
beatmap.Stages.Add(new StageDefinition(TargetColumns));
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||
@ -15,7 +16,15 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
||||
/// <summary>
|
||||
/// The number of <see cref="Column"/>s which this stage contains.
|
||||
/// </summary>
|
||||
public int Columns;
|
||||
public readonly int Columns;
|
||||
|
||||
public StageDefinition(int columns)
|
||||
{
|
||||
if (columns < 1)
|
||||
throw new ArgumentException("Column count must be above zero.", nameof(columns));
|
||||
|
||||
Columns = columns;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the column index is a special column for this stage.
|
||||
|
@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
||||
isLegacySkin = new Lazy<bool>(() => GetConfig<SkinConfiguration.LegacySetting, decimal>(SkinConfiguration.LegacySetting.Version) != null);
|
||||
hasKeyTexture = new Lazy<bool>(() =>
|
||||
{
|
||||
string keyImage = this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, new StageDefinition { Columns = 1 }, 0)?.Value ?? "mania-key1";
|
||||
string keyImage = this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, new StageDefinition(1), 0)?.Value ?? "mania-key1";
|
||||
return this.GetAnimation(keyImage, true, true) != null;
|
||||
});
|
||||
}
|
||||
@ -125,7 +125,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
||||
if (!hit_result_mapping.ContainsKey(result))
|
||||
return null;
|
||||
|
||||
string filename = this.GetManiaSkinConfig<string>(hit_result_mapping[result], new StageDefinition())?.Value
|
||||
string filename = this.GetManiaSkinConfig<string>(hit_result_mapping[result], new StageDefinition(1))?.Value
|
||||
?? default_hit_result_skin_filenames[result];
|
||||
|
||||
var animation = this.GetAnimation(filename, true, true);
|
||||
|
Loading…
Reference in New Issue
Block a user