1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-31 19:10:43 +08:00

Merge branch 'master' into add-mod-search-option

This commit is contained in:
Cootz
2023-05-23 08:55:57 +03:00
committed by GitHub
Unverified
220 changed files with 3565 additions and 1255 deletions
@@ -14,6 +14,7 @@ using osu.Framework.Localisation;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets;
@@ -21,6 +22,7 @@ using osu.Game.Rulesets.Catch.Mods;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Taiko.Mods;
using osu.Game.Tests.Mods;
using osuTK;
using osuTK.Input;
@@ -67,6 +69,19 @@ namespace osu.Game.Tests.Visual.UserInterface
}
}
});
r.Add(new ModPreset
{
Name = "Half Time 0.5x",
Description = "Very slow",
Ruleset = r.Find<RulesetInfo>(OsuRuleset.SHORT_NAME),
Mods = new[]
{
new OsuModHalfTime
{
SpeedChange = { Value = 0.5 }
}
}
});
});
});
}
@@ -371,6 +386,50 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("no mod selected", () => SelectedMods.Value.Count == 0);
}
[Test]
public void TestKeepSharedSettingsFromSimilarMods()
{
const float setting_change = 1.2f;
createScreen();
changeRuleset(0);
AddStep("select difficulty adjust mod", () => SelectedMods.Value = new[] { Ruleset.Value.CreateInstance().CreateMod<ModDifficultyAdjust>()! });
changeRuleset(0);
AddAssert("ensure mod still selected", () => SelectedMods.Value.SingleOrDefault() is OsuModDifficultyAdjust);
AddStep("change mod settings", () =>
{
var osuMod = getSelectedMod<OsuModDifficultyAdjust>();
osuMod.ExtendedLimits.Value = true;
osuMod.CircleSize.Value = setting_change;
osuMod.DrainRate.Value = setting_change;
osuMod.OverallDifficulty.Value = setting_change;
osuMod.ApproachRate.Value = setting_change;
});
changeRuleset(1);
AddAssert("taiko variant selected", () => SelectedMods.Value.SingleOrDefault() is TaikoModDifficultyAdjust);
AddAssert("shared settings preserved", () =>
{
var taikoMod = getSelectedMod<TaikoModDifficultyAdjust>();
return taikoMod.ExtendedLimits.Value &&
taikoMod.DrainRate.Value == setting_change &&
taikoMod.OverallDifficulty.Value == setting_change;
});
AddAssert("non-shared settings remain default", () =>
{
var taikoMod = getSelectedMod<TaikoModDifficultyAdjust>();
return taikoMod.ScrollSpeed.IsDefault;
});
}
[Test]
public void TestExternallySetCustomizedMod()
{
@@ -700,6 +759,28 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("5 columns visible", () => this.ChildrenOfType<ModColumn>().Count(col => col.IsPresent) == 5);
}
[Test]
public void TestModMultiplierUpdates()
{
createScreen();
AddStep("select mod preset with half time", () =>
{
InputManager.MoveMouseTo(this.ChildrenOfType<ModPresetPanel>().Single(preset => preset.Preset.Value.Name == "Half Time 0.5x"));
InputManager.Click(MouseButton.Left);
});
AddAssert("difficulty multiplier display shows correct value", () => modSelectOverlay.ChildrenOfType<DifficultyMultiplierDisplay>().Single().Current.Value, () => Is.EqualTo(0.5));
// this is highly unorthodox in a test, but because the `ModSettingChangeTracker` machinery heavily leans on events and object disposal and re-creation,
// it is instrumental in the reproduction of the failure scenario that this test is supposed to cover.
AddStep("force collection", GC.Collect);
AddStep("open customisation area", () => modSelectOverlay.CustomisationButton!.TriggerClick());
AddStep("reset half time speed to default", () => modSelectOverlay.ChildrenOfType<ModSettingsArea>().Single()
.ChildrenOfType<RestoreDefaultValueButton<double>>().Single().TriggerClick());
AddUntilStep("difficulty multiplier display shows correct value", () => modSelectOverlay.ChildrenOfType<DifficultyMultiplierDisplay>().Single().Current.Value, () => Is.EqualTo(0.7));
}
private void waitForColumnLoad() => AddUntilStep("all column content loaded",
() => modSelectOverlay.ChildrenOfType<ModColumn>().Any() && modSelectOverlay.ChildrenOfType<ModColumn>().All(column => column.IsLoaded && column.ItemsLoaded));
@@ -715,6 +796,8 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert($"customisation toggle is {(active ? "" : "not ")}active", () => modSelectOverlay.CustomisationButton.AsNonNull().Active.Value == active);
}
private T getSelectedMod<T>() where T : Mod => SelectedMods.Value.OfType<T>().Single();
private ModPanel getPanelForMod(Type modType)
=> modSelectOverlay.ChildrenOfType<ModPanel>().Single(panel => panel.Mod.GetType() == modType);