2022-07-22 19:05:02 +00:00
|
|
|
// 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 System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2022-07-23 16:01:11 +00:00
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2022-07-22 19:05:02 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-07-23 16:01:11 +00:00
|
|
|
using osu.Framework.Testing;
|
2022-07-22 19:05:02 +00:00
|
|
|
using osu.Game.Overlays;
|
|
|
|
using osu.Game.Overlays.Mods;
|
2022-07-23 16:01:11 +00:00
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Rulesets.Mania.Mods;
|
2022-07-22 19:05:02 +00:00
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
{
|
|
|
|
public class TestSceneModPresetColumn : OsuTestScene
|
|
|
|
{
|
2022-07-23 16:01:11 +00:00
|
|
|
protected override bool UseFreshStoragePerRun => true;
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private RulesetStore rulesets { get; set; } = null!;
|
|
|
|
|
2022-07-22 19:05:02 +00:00
|
|
|
[Cached]
|
|
|
|
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
|
|
|
|
2022-07-23 16:01:11 +00:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Dependencies.Cache(Realm);
|
|
|
|
}
|
|
|
|
|
|
|
|
[SetUpSteps]
|
|
|
|
public void SetUpSteps()
|
|
|
|
{
|
|
|
|
AddStep("reset storage", () =>
|
|
|
|
{
|
|
|
|
Realm.Write(realm =>
|
|
|
|
{
|
|
|
|
realm.RemoveAll<ModPreset>();
|
|
|
|
realm.Add(createTestPresets());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-07-22 19:05:02 +00:00
|
|
|
[Test]
|
2022-07-23 16:09:27 +00:00
|
|
|
public void TestBasicOperation()
|
2022-07-22 19:05:02 +00:00
|
|
|
{
|
2022-07-23 16:01:11 +00:00
|
|
|
AddStep("set osu! ruleset", () => Ruleset.Value = rulesets.GetRuleset(0));
|
2022-07-22 19:05:02 +00:00
|
|
|
AddStep("create content", () => Child = new Container
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Padding = new MarginPadding(30),
|
2022-07-23 16:01:11 +00:00
|
|
|
Child = new ModPresetColumn
|
2022-07-22 19:05:02 +00:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
}
|
|
|
|
});
|
2022-07-23 16:01:11 +00:00
|
|
|
AddUntilStep("3 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 3);
|
|
|
|
|
|
|
|
AddStep("change ruleset to mania", () => Ruleset.Value = rulesets.GetRuleset(3));
|
|
|
|
AddUntilStep("1 panel visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 1);
|
2022-07-23 16:09:27 +00:00
|
|
|
|
|
|
|
AddStep("add another mania preset", () => Realm.Write(r => r.Add(new ModPreset
|
|
|
|
{
|
|
|
|
Name = "and another one",
|
|
|
|
Mods = new Mod[]
|
|
|
|
{
|
|
|
|
new ManiaModMirror(),
|
|
|
|
new ManiaModNightcore(),
|
|
|
|
new ManiaModHardRock()
|
|
|
|
},
|
|
|
|
Ruleset = rulesets.GetRuleset(3).AsNonNull()
|
|
|
|
})));
|
|
|
|
AddUntilStep("2 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 2);
|
|
|
|
|
|
|
|
AddStep("add another osu! preset", () => Realm.Write(r => r.Add(new ModPreset
|
|
|
|
{
|
|
|
|
Name = "hdhr",
|
|
|
|
Mods = new Mod[]
|
|
|
|
{
|
|
|
|
new OsuModHidden(),
|
|
|
|
new OsuModHardRock()
|
|
|
|
},
|
|
|
|
Ruleset = rulesets.GetRuleset(0).AsNonNull()
|
|
|
|
})));
|
|
|
|
AddUntilStep("2 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 2);
|
|
|
|
|
|
|
|
AddStep("remove mania preset", () => Realm.Write(r =>
|
|
|
|
{
|
|
|
|
var toRemove = r.All<ModPreset>().Single(preset => preset.Name == "Different ruleset");
|
|
|
|
r.Remove(toRemove);
|
|
|
|
}));
|
|
|
|
AddUntilStep("1 panel visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 1);
|
|
|
|
|
|
|
|
AddStep("set osu! ruleset", () => Ruleset.Value = rulesets.GetRuleset(0));
|
|
|
|
AddUntilStep("4 panels visible", () => this.ChildrenOfType<ModPresetPanel>().Count() == 4);
|
2022-07-22 19:05:02 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 16:01:11 +00:00
|
|
|
private IEnumerable<ModPreset> createTestPresets() => new[]
|
2022-07-22 19:05:02 +00:00
|
|
|
{
|
|
|
|
new ModPreset
|
|
|
|
{
|
|
|
|
Name = "First preset",
|
|
|
|
Description = "Please ignore",
|
|
|
|
Mods = new Mod[]
|
|
|
|
{
|
|
|
|
new OsuModHardRock(),
|
|
|
|
new OsuModDoubleTime()
|
2022-07-23 16:01:11 +00:00
|
|
|
},
|
|
|
|
Ruleset = rulesets.GetRuleset(0).AsNonNull()
|
2022-07-22 19:05:02 +00:00
|
|
|
},
|
|
|
|
new ModPreset
|
|
|
|
{
|
|
|
|
Name = "AR0",
|
|
|
|
Description = "For good readers",
|
|
|
|
Mods = new Mod[]
|
|
|
|
{
|
|
|
|
new OsuModDifficultyAdjust
|
|
|
|
{
|
|
|
|
ApproachRate = { Value = 0 }
|
|
|
|
}
|
2022-07-23 16:01:11 +00:00
|
|
|
},
|
|
|
|
Ruleset = rulesets.GetRuleset(0).AsNonNull()
|
2022-07-22 19:05:02 +00:00
|
|
|
},
|
|
|
|
new ModPreset
|
|
|
|
{
|
|
|
|
Name = "This preset is going to have an extraordinarily long name",
|
|
|
|
Description = "This is done so that the capability to truncate overlong texts may be demonstrated",
|
|
|
|
Mods = new Mod[]
|
|
|
|
{
|
|
|
|
new OsuModFlashlight(),
|
|
|
|
new OsuModSpinIn()
|
2022-07-23 16:01:11 +00:00
|
|
|
},
|
|
|
|
Ruleset = rulesets.GetRuleset(0).AsNonNull()
|
|
|
|
},
|
|
|
|
new ModPreset
|
|
|
|
{
|
|
|
|
Name = "Different ruleset",
|
|
|
|
Description = "Just to shake things up",
|
|
|
|
Mods = new Mod[]
|
|
|
|
{
|
|
|
|
new ManiaModKey4(),
|
|
|
|
new ManiaModFadeIn()
|
|
|
|
},
|
|
|
|
Ruleset = rulesets.GetRuleset(3).AsNonNull()
|
2022-07-22 19:05:02 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|