mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 04:02:57 +08:00
Merge branch 'master' into player-mod-reinstantiation
This commit is contained in:
commit
bb539af1a0
@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
SelectedMods.Value = SelectedMods.Value.Concat(new[] { ruleset.GetAutoplayMod() });
|
||||
Mods.Value = Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
||||
return base.CreatePlayer(ruleset);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Catch
|
||||
{
|
||||
public class CatchRuleset : Ruleset
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IEnumerable<Mod> mods) => new DrawableCatchRuleset(this, beatmap, mods);
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableCatchRuleset(this, beatmap, mods);
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new CatchBeatmapConverter(beatmap);
|
||||
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new CatchBeatmapProcessor(beatmap);
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
protected override bool UserScrollSpeedAdjustment => false;
|
||||
|
||||
public DrawableCatchRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IEnumerable<Mod> mods)
|
||||
public DrawableCatchRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
Direction.Value = ScrollingDirection.Down;
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -8,6 +10,7 @@ using osu.Framework.Timing;
|
||||
using osu.Game.Rulesets.Mania.Edit;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Tests.Visual;
|
||||
@ -21,6 +24,9 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
private readonly Column column;
|
||||
|
||||
[Cached(typeof(IReadOnlyList<Mod>))]
|
||||
private IReadOnlyList<Mod> mods { get; set; } = Array.Empty<Mod>();
|
||||
|
||||
protected ManiaPlacementBlueprintTestCase()
|
||||
{
|
||||
Add(column = new Column(0)
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.Mania.UI.Components;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
@ -31,6 +32,9 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
typeof(ColumnHitObjectArea)
|
||||
};
|
||||
|
||||
[Cached(typeof(IReadOnlyList<Mod>))]
|
||||
private IReadOnlyList<Mod> mods { get; set; } = Array.Empty<Mod>();
|
||||
|
||||
private readonly List<Column> columns = new List<Column>();
|
||||
|
||||
public TestCaseColumn()
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
@ -13,6 +14,7 @@ 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;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
@ -24,6 +26,9 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
{
|
||||
private const int columns = 4;
|
||||
|
||||
[Cached(typeof(IReadOnlyList<Mod>))]
|
||||
private IReadOnlyList<Mod> mods { get; set; } = Array.Empty<Mod>();
|
||||
|
||||
private readonly List<ManiaStage> stages = new List<ManiaStage>();
|
||||
|
||||
private FillFlowContainer<ScrollingTestContainer> fill;
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
{
|
||||
public new IScrollingInfo ScrollingInfo => base.ScrollingInfo;
|
||||
|
||||
public DrawableManiaEditRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IEnumerable<Mod> mods)
|
||||
public DrawableManiaEditRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
||||
|
||||
public int TotalColumns => ((ManiaPlayfield)DrawableRuleset.Playfield).TotalColumns;
|
||||
|
||||
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IEnumerable<Mod> mods)
|
||||
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
{
|
||||
DrawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap, mods);
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Mania
|
||||
{
|
||||
public class ManiaRuleset : Ruleset
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IEnumerable<Mod> mods) => new DrawableManiaRuleset(this, beatmap, mods);
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableManiaRuleset(this, beatmap, mods);
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap);
|
||||
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
|
||||
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
||||
|
||||
public DrawableManiaRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IEnumerable<Mod> mods)
|
||||
public DrawableManiaRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
// Generate the bar lines
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -23,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
var beatmap = Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
|
||||
var converted = new TestWorkingBeatmap(beatmap).GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Enumerable.Empty<Mod>());
|
||||
var converted = new TestWorkingBeatmap(beatmap).GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty<Mod>());
|
||||
|
||||
var objects = converted.HitObjects.ToList();
|
||||
|
||||
|
@ -30,7 +30,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private int depthIndex;
|
||||
protected readonly List<Mod> Mods = new List<Mod>();
|
||||
|
||||
public TestCaseHitCircle()
|
||||
{
|
||||
@ -68,7 +67,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
Depth = depthIndex++
|
||||
};
|
||||
|
||||
foreach (var mod in Mods.OfType<IApplicableToDrawableHitObjects>())
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||
|
||||
Add(drawable);
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
public TestCaseHitCircleHidden()
|
||||
{
|
||||
Mods.Add(new OsuModHidden());
|
||||
Mods.Value = new[] { new OsuModHidden() };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private int depthIndex;
|
||||
protected readonly List<Mod> Mods = new List<Mod>();
|
||||
|
||||
public TestCaseSlider()
|
||||
{
|
||||
@ -292,7 +291,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
Depth = depthIndex++
|
||||
};
|
||||
|
||||
foreach (var mod in Mods.OfType<IApplicableToDrawableHitObjects>())
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||
|
||||
drawable.OnNewResult += onNewResult;
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
public TestCaseSliderHidden()
|
||||
{
|
||||
Mods.Add(new OsuModHidden());
|
||||
Mods.Value = new[] { new OsuModHidden() };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private int depthIndex;
|
||||
protected readonly List<Mod> Mods = new List<Mod>();
|
||||
|
||||
public TestCaseSpinner()
|
||||
{
|
||||
@ -57,7 +56,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
Depth = depthIndex++
|
||||
};
|
||||
|
||||
foreach (var mod in Mods.OfType<IApplicableToDrawableHitObjects>())
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||
|
||||
Add(drawable);
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
|
||||
public TestCaseSpinnerHidden()
|
||||
{
|
||||
Mods.Add(new OsuModHidden());
|
||||
Mods.Value = new[] { new OsuModHidden() };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
public class DrawableOsuEditRuleset : DrawableOsuRuleset
|
||||
{
|
||||
public DrawableOsuEditRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IEnumerable<Mod> mods)
|
||||
public DrawableOsuEditRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
}
|
||||
|
||||
protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IEnumerable<Mod> mods)
|
||||
protected override DrawableRuleset<OsuHitObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
=> new DrawableOsuEditRuleset(ruleset, beatmap, mods);
|
||||
|
||||
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
|
||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
{
|
||||
public class OsuRuleset : Ruleset
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IEnumerable<Mod> mods) => new DrawableOsuRuleset(this, beatmap, mods);
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableOsuRuleset(this, beatmap, mods);
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new OsuBeatmapConverter(beatmap);
|
||||
public override IBeatmapProcessor CreateBeatmapProcessor(IBeatmap beatmap) => new OsuBeatmapProcessor(beatmap);
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
protected new OsuRulesetConfigManager Config => (OsuRulesetConfigManager)base.Config;
|
||||
|
||||
public DrawableOsuRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IEnumerable<Mod> mods)
|
||||
public DrawableOsuRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
@ -88,7 +87,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 768,
|
||||
Children = new[] { drawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap, Enumerable.Empty<Mod>()) }
|
||||
Children = new[] { drawableRuleset = new DrawableTaikoRuleset(new TaikoRuleset(), beatmap, Array.Empty<Mod>()) }
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Taiko
|
||||
{
|
||||
public class TaikoRuleset : Ruleset
|
||||
{
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IEnumerable<Mod> mods) => new DrawableTaikoRuleset(this, beatmap, mods);
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods) => new DrawableTaikoRuleset(this, beatmap, mods);
|
||||
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new TaikoBeatmapConverter(beatmap);
|
||||
|
||||
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
protected override bool UserScrollSpeedAdjustment => false;
|
||||
|
||||
public DrawableTaikoRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IEnumerable<Mod> mods)
|
||||
public DrawableTaikoRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
Direction.Value = ScrollingDirection.Left;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using osuTK;
|
||||
@ -40,7 +41,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
||||
|
||||
Assert.AreEqual(6, working.BeatmapInfo.BeatmapVersion);
|
||||
Assert.AreEqual(6, working.Beatmap.BeatmapInfo.BeatmapVersion);
|
||||
Assert.AreEqual(6, working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Enumerable.Empty<Mod>()).BeatmapInfo.BeatmapVersion);
|
||||
Assert.AreEqual(6, working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty<Mod>()).BeatmapInfo.BeatmapVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ namespace osu.Game.Tests.Visual.Background
|
||||
AddUntilStep("Song select has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
||||
AddStep("Set default user settings", () =>
|
||||
{
|
||||
SelectedMods.Value = SelectedMods.Value.Concat(new[] { new OsuModNoFail() });
|
||||
Mods.Value = Mods.Value.Concat(new[] { new OsuModNoFail() }).ToArray();
|
||||
songSelect.DimLevel.Value = 0.7f;
|
||||
songSelect.BlurLevel.Value = 0.4f;
|
||||
});
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
SelectedMods.Value = SelectedMods.Value.Concat(new[] { ruleset.GetAutoplayMod() });
|
||||
Mods.Value = Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() }).ToArray();
|
||||
return new ScoreAccessiblePlayer();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets;
|
||||
@ -16,7 +17,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
var beatmap = Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo, Enumerable.Empty<Mod>());
|
||||
var beatmap = Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo, Array.Empty<Mod>());
|
||||
|
||||
return new ScoreAccessibleReplayPlayer(ruleset.GetAutoplayMod().CreateReplayScore(beatmap));
|
||||
}
|
||||
|
@ -4,11 +4,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Timing;
|
||||
@ -23,6 +25,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Playfield) };
|
||||
|
||||
[Cached(typeof(IReadOnlyList<Mod>))]
|
||||
private IReadOnlyList<Mod> mods { get; set; } = Array.Empty<Mod>();
|
||||
|
||||
private readonly ScrollingTestContainer[] scrollContainers = new ScrollingTestContainer[4];
|
||||
private readonly TestPlayfield[] playfields = new TestPlayfield[4];
|
||||
|
||||
|
@ -171,19 +171,19 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
AddStep("change ruleset", () =>
|
||||
{
|
||||
SelectedMods.ValueChanged += onModChange;
|
||||
Mods.ValueChanged += onModChange;
|
||||
songSelect.Ruleset.ValueChanged += onRulesetChange;
|
||||
|
||||
Ruleset.Value = new TaikoRuleset().RulesetInfo;
|
||||
|
||||
SelectedMods.ValueChanged -= onModChange;
|
||||
Mods.ValueChanged -= onModChange;
|
||||
songSelect.Ruleset.ValueChanged -= onRulesetChange;
|
||||
});
|
||||
|
||||
AddAssert("mods changed before ruleset", () => modChangeIndex < rulesetChangeIndex);
|
||||
AddAssert("empty mods", () => !SelectedMods.Value.Any());
|
||||
AddAssert("empty mods", () => !Mods.Value.Any());
|
||||
|
||||
void onModChange(ValueChangedEvent<IEnumerable<Mod>> e) => modChangeIndex = actionIndex++;
|
||||
void onModChange(ValueChangedEvent<IReadOnlyList<Mod>> e) => modChangeIndex = actionIndex++;
|
||||
void onRulesetChange(ValueChangedEvent<RulesetInfo> e) => rulesetChangeIndex = actionIndex--;
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
private static int importId;
|
||||
private int getImportId() => ++importId;
|
||||
|
||||
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => SelectedMods.Value = mods);
|
||||
private void changeMods(params Mod[] mods) => AddStep($"change mods to {string.Join(", ", mods.Select(m => m.Acronym))}", () => Mods.Value = mods);
|
||||
|
||||
private void changeRuleset(int id) => AddStep($"change ruleset to {id}", () => Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == id));
|
||||
|
||||
|
@ -253,7 +253,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private class TestModSelectOverlay : ModSelectOverlay
|
||||
{
|
||||
public new Bindable<IEnumerable<Mod>> SelectedMods => base.SelectedMods;
|
||||
public new Bindable<IReadOnlyList<Mod>> SelectedMods => base.SelectedMods;
|
||||
|
||||
public ModButton GetModButton(Mod mod)
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
|
||||
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IEnumerable<Mod> mods)
|
||||
public override DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <param name="ruleset">The <see cref="RulesetInfo"/> to create a playable <see cref="IBeatmap"/> for.</param>
|
||||
/// <returns>The converted <see cref="IBeatmap"/>.</returns>
|
||||
/// <exception cref="BeatmapInvalidForRulesetException">If <see cref="Beatmap"/> could not be converted to <paramref name="ruleset"/>.</exception>
|
||||
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IEnumerable<Mod> mods)
|
||||
public IBeatmap GetPlayableBeatmap(RulesetInfo ruleset, IReadOnlyList<Mod> mods)
|
||||
{
|
||||
var rulesetInstance = ruleset.CreateInstance();
|
||||
|
||||
|
@ -112,8 +112,8 @@ namespace osu.Game
|
||||
|
||||
// todo: move this to SongSelect once Screen has the ability to unsuspend.
|
||||
[Cached]
|
||||
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
||||
private readonly Bindable<IEnumerable<Mod>> selectedMods = new Bindable<IEnumerable<Mod>>(Enumerable.Empty<Mod>());
|
||||
[Cached(typeof(IBindable<IReadOnlyList<Mod>>))]
|
||||
private readonly Bindable<IReadOnlyList<Mod>> mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
public OsuGame(string[] args = null)
|
||||
{
|
||||
@ -294,7 +294,7 @@ namespace osu.Game
|
||||
{
|
||||
ruleset.Value = databasedScoreInfo.Ruleset;
|
||||
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(databasedBeatmap);
|
||||
selectedMods.Value = databasedScoreInfo.Mods;
|
||||
mods.Value = databasedScoreInfo.Mods;
|
||||
|
||||
menuScreen.Push(new PlayerLoader(() => new ReplayPlayer(databasedScore)));
|
||||
}, $"watch {databasedScoreInfo}", bypassScreenAllowChecks: true);
|
||||
|
@ -42,19 +42,19 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
protected readonly FillFlowContainer<ModSection> ModSectionsContainer;
|
||||
|
||||
protected readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(new Mod[] { });
|
||||
protected readonly Bindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
protected readonly IBindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuColour colours, IBindable<RulesetInfo> ruleset, AudioManager audio, Bindable<IEnumerable<Mod>> selectedMods)
|
||||
private void load(OsuColour colours, IBindable<RulesetInfo> ruleset, AudioManager audio, Bindable<IReadOnlyList<Mod>> mods)
|
||||
{
|
||||
LowMultiplierColour = colours.Red;
|
||||
HighMultiplierColour = colours.Green;
|
||||
UnrankedLabel.Colour = colours.Blue;
|
||||
|
||||
Ruleset.BindTo(ruleset);
|
||||
if (selectedMods != null) SelectedMods.BindTo(selectedMods);
|
||||
if (mods != null) SelectedMods.BindTo(mods);
|
||||
|
||||
sampleOn = audio.Sample.Get(@"UI/check-on");
|
||||
sampleOff = audio.Sample.Get(@"UI/check-off");
|
||||
@ -87,14 +87,14 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
// attempt to re-select any already selected mods.
|
||||
// this may be the first time we are receiving the ruleset, in which case they will still match.
|
||||
selectedModsChanged(new ValueChangedEvent<IEnumerable<Mod>>(SelectedMods.Value, SelectedMods.Value));
|
||||
selectedModsChanged(new ValueChangedEvent<IReadOnlyList<Mod>>(SelectedMods.Value, SelectedMods.Value));
|
||||
|
||||
// write the mods back to the SelectedMods bindable in the case a change was not applicable.
|
||||
// this generally isn't required as the previous line will perform deselection; just here for safety.
|
||||
refreshSelectedMods();
|
||||
}
|
||||
|
||||
private void selectedModsChanged(ValueChangedEvent<IEnumerable<Mod>> e)
|
||||
private void selectedModsChanged(ValueChangedEvent<IReadOnlyList<Mod>> e)
|
||||
{
|
||||
foreach (ModSection section in ModSectionsContainer.Children)
|
||||
section.SelectTypes(e.NewValue.Select(m => m.GetType()).ToList());
|
||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Overlays
|
||||
private Bindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IBindable<IEnumerable<Mod>> selectedMods { get; set; }
|
||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Provide a source for the toolbar height.
|
||||
@ -235,7 +235,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
beatmap.BindValueChanged(beatmapChanged, true);
|
||||
beatmap.BindDisabledChanged(beatmapDisabledChanged, true);
|
||||
selectedMods.BindValueChanged(_ => updateAudioAdjustments(), true);
|
||||
mods.BindValueChanged(_ => updateAudioAdjustments(), true);
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
@ -372,7 +372,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
track.ResetSpeedAdjustments();
|
||||
|
||||
foreach (var mod in selectedMods.Value.OfType<IApplicableToClock>())
|
||||
foreach (var mod in mods.Value.OfType<IApplicableToClock>())
|
||||
mod.ApplyToClock(track);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Difficulty
|
||||
/// </summary>
|
||||
public Mod[] CreateDifficultyAdjustmentModCombinations()
|
||||
{
|
||||
return createDifficultyAdjustmentModCombinations(Enumerable.Empty<Mod>(), DifficultyAdjustmentMods).ToArray();
|
||||
return createDifficultyAdjustmentModCombinations(Array.Empty<Mod>(), DifficultyAdjustmentMods).ToArray();
|
||||
|
||||
IEnumerable<Mod> createDifficultyAdjustmentModCombinations(IEnumerable<Mod> currentSet, Mod[] adjustmentSet, int currentSetCount = 0, int adjustmentSetStart = 0)
|
||||
{
|
||||
|
@ -186,8 +186,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
|
||||
internal override DrawableEditRuleset CreateDrawableRuleset()
|
||||
=> new DrawableEditRuleset<TObject>(CreateDrawableRuleset(Ruleset, Beatmap.Value, Enumerable.Empty<Mod>()));
|
||||
=> new DrawableEditRuleset<TObject>(CreateDrawableRuleset(Ruleset, Beatmap.Value, Array.Empty<Mod>()));
|
||||
|
||||
protected abstract DrawableRuleset<TObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IEnumerable<Mod> mods);
|
||||
protected abstract DrawableRuleset<TObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Rulesets
|
||||
/// <param name="beatmap">The beatmap to create the hit renderer for.</param>
|
||||
/// <exception cref="BeatmapInvalidForRulesetException">Unable to successfully load the beatmap to be usable with this ruleset.</exception>
|
||||
/// <returns></returns>
|
||||
public abstract DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IEnumerable<Mod> mods);
|
||||
public abstract DrawableRuleset CreateDrawableRulesetWith(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> to one that is applicable for this <see cref="Ruleset"/>.
|
||||
|
@ -81,9 +81,8 @@ namespace osu.Game.Rulesets.UI
|
||||
/// <summary>
|
||||
/// The mods which are to be applied.
|
||||
/// </summary>
|
||||
[Cached]
|
||||
[Cached(typeof(IBindable<IEnumerable<Mod>>))]
|
||||
private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>();
|
||||
[Cached(typeof(IReadOnlyList<Mod>))]
|
||||
private readonly IReadOnlyList<Mod> mods;
|
||||
|
||||
private FrameStabilityContainer frameStabilityContainer;
|
||||
|
||||
@ -94,13 +93,13 @@ namespace osu.Game.Rulesets.UI
|
||||
/// </summary>
|
||||
/// <param name="ruleset">The ruleset being represented.</param>
|
||||
/// <param name="workingBeatmap">The beatmap to create the hit renderer for.</param>
|
||||
protected DrawableRuleset(Ruleset ruleset, WorkingBeatmap workingBeatmap, IEnumerable<Mod> mods)
|
||||
protected DrawableRuleset(Ruleset ruleset, WorkingBeatmap workingBeatmap, IReadOnlyList<Mod> mods)
|
||||
: base(ruleset)
|
||||
{
|
||||
if (workingBeatmap == null)
|
||||
throw new ArgumentException("Beatmap cannot be null.", nameof(workingBeatmap));
|
||||
|
||||
this.mods.Value = mods;
|
||||
this.mods = mods.ToArray();
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
@ -160,7 +159,7 @@ namespace osu.Game.Rulesets.UI
|
||||
.WithChild(ResumeOverlay)));
|
||||
}
|
||||
|
||||
applyRulesetMods(mods.Value, config);
|
||||
applyRulesetMods(mods, config);
|
||||
|
||||
loadObjects();
|
||||
}
|
||||
@ -175,7 +174,7 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
Playfield.PostProcess();
|
||||
|
||||
foreach (var mod in mods.Value.OfType<IApplicableToDrawableHitObjects>())
|
||||
foreach (var mod in mods.OfType<IApplicableToDrawableHitObjects>())
|
||||
mod.ApplyToDrawableHitObjects(Playfield.HitObjectContainer.Objects);
|
||||
}
|
||||
|
||||
@ -258,7 +257,7 @@ namespace osu.Game.Rulesets.UI
|
||||
/// Applies the active mods to the Beatmap.
|
||||
/// </summary>
|
||||
/// <param name="mods"></param>
|
||||
private void applyBeatmapMods(IEnumerable<Mod> mods)
|
||||
private void applyBeatmapMods(IReadOnlyList<Mod> mods)
|
||||
{
|
||||
if (mods == null)
|
||||
return;
|
||||
@ -271,7 +270,7 @@ namespace osu.Game.Rulesets.UI
|
||||
/// Applies the active mods to this DrawableRuleset.
|
||||
/// </summary>
|
||||
/// <param name="mods"></param>
|
||||
private void applyRulesetMods(IEnumerable<Mod> mods, OsuConfigManager config)
|
||||
private void applyRulesetMods(IReadOnlyList<Mod> mods, OsuConfigManager config)
|
||||
{
|
||||
if (mods == null)
|
||||
return;
|
||||
|
@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
if (Math.Abs(manualClock.CurrentTime - newProposedTime) > sixty_frame_time * 1.2f)
|
||||
{
|
||||
newProposedTime = manualClock.Rate > 0
|
||||
newProposedTime = newProposedTime > manualClock.CurrentTime
|
||||
? Math.Min(newProposedTime, manualClock.CurrentTime + sixty_frame_time)
|
||||
: Math.Max(newProposedTime, manualClock.CurrentTime - sixty_frame_time);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.UI
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IBindable<IEnumerable<Mod>> selectedMods { get; set; }
|
||||
private IReadOnlyList<Mod> mods { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
@ -125,7 +125,7 @@ namespace osu.Game.Rulesets.UI
|
||||
base.Update();
|
||||
|
||||
if (beatmap != null)
|
||||
foreach (var mod in selectedMods.Value)
|
||||
foreach (var mod in mods)
|
||||
if (mod is IUpdatableByPlayfield updatable)
|
||||
updatable.Update(this);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
||||
[Cached(Type = typeof(IScrollingInfo))]
|
||||
private readonly LocalScrollingInfo scrollingInfo;
|
||||
|
||||
protected DrawableScrollingRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IEnumerable<Mod> mods)
|
||||
protected DrawableScrollingRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
scrollingInfo = new LocalScrollingInfo();
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
@ -110,7 +109,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
},
|
||||
};
|
||||
|
||||
CurrentItem.BindValueChanged(item => modDisplay.Current.Value = item.NewValue?.RequiredMods ?? Enumerable.Empty<Mod>(), true);
|
||||
CurrentItem.BindValueChanged(item => modDisplay.Current.Value = item.NewValue?.RequiredMods?.ToArray() ?? Array.Empty<Mod>(), true);
|
||||
|
||||
beatmapButton.Action = () => RequestBeatmapSelection?.Invoke();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// 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.Linq;
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
@ -179,7 +179,7 @@ namespace osu.Game.Screens.Multi.Match
|
||||
{
|
||||
RoomManager?.PartRoom();
|
||||
|
||||
SelectedMods.Value = Enumerable.Empty<Mod>();
|
||||
Mods.Value = Array.Empty<Mod>();
|
||||
|
||||
return base.OnExiting(next);
|
||||
}
|
||||
@ -193,7 +193,7 @@ namespace osu.Game.Screens.Multi.Match
|
||||
var localBeatmap = e.NewValue?.Beatmap == null ? null : beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == e.NewValue.Beatmap.OnlineBeatmapID);
|
||||
|
||||
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
||||
SelectedMods.Value = e.NewValue?.RequiredMods ?? Enumerable.Empty<Mod>();
|
||||
Mods.Value = e.NewValue?.RequiredMods?.ToArray() ?? Array.Empty<Mod>();
|
||||
if (e.NewValue?.Ruleset != null)
|
||||
Ruleset.Value = e.NewValue.Ruleset;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace osu.Game.Screens.Multi.Play
|
||||
if (ruleset.Value.ID != playlistItem.Ruleset.ID)
|
||||
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
|
||||
|
||||
if (!playlistItem.RequiredMods.All(m => SelectedMods.Value.Contains(m)))
|
||||
if (!playlistItem.RequiredMods.All(m => Mods.Value.Contains(m)))
|
||||
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
|
||||
|
||||
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID);
|
||||
|
@ -65,7 +65,7 @@ namespace osu.Game.Screens
|
||||
|
||||
public Bindable<RulesetInfo> Ruleset { get; private set; }
|
||||
|
||||
public Bindable<IEnumerable<Mod>> SelectedMods { get; private set; }
|
||||
public Bindable<IReadOnlyList<Mod>> Mods { get; private set; }
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
@ -73,7 +73,7 @@ namespace osu.Game.Screens
|
||||
|
||||
Beatmap = screenDependencies.Beatmap;
|
||||
Ruleset = screenDependencies.Ruleset;
|
||||
SelectedMods = screenDependencies.SelectedMods;
|
||||
Mods = screenDependencies.Mods;
|
||||
|
||||
return base.CreateChildDependencies(screenDependencies);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Screens
|
||||
|
||||
public Bindable<RulesetInfo> Ruleset { get; }
|
||||
|
||||
public Bindable<IEnumerable<Mod>> SelectedMods { get; }
|
||||
public Bindable<IReadOnlyList<Mod>> Mods { get; }
|
||||
|
||||
public OsuScreenDependencies(bool requireLease, IReadOnlyDependencyContainer parent)
|
||||
: base(parent)
|
||||
@ -31,15 +31,15 @@ namespace osu.Game.Screens
|
||||
if (Ruleset == null)
|
||||
Cache(Ruleset = parent.Get<Bindable<RulesetInfo>>().BeginLease(true));
|
||||
|
||||
SelectedMods = parent.Get<LeasedBindable<IEnumerable<Mod>>>()?.GetBoundCopy();
|
||||
if (SelectedMods == null)
|
||||
Cache(SelectedMods = parent.Get<Bindable<IEnumerable<Mod>>>().BeginLease(true));
|
||||
Mods = parent.Get<LeasedBindable<IReadOnlyList<Mod>>>()?.GetBoundCopy();
|
||||
if (Mods == null)
|
||||
Cache(Mods = parent.Get<Bindable<IReadOnlyList<Mod>>>().BeginLease(true));
|
||||
}
|
||||
else
|
||||
{
|
||||
Beatmap = (parent.Get<LeasedBindable<WorkingBeatmap>>() ?? parent.Get<Bindable<WorkingBeatmap>>()).GetBoundCopy();
|
||||
Ruleset = (parent.Get<LeasedBindable<RulesetInfo>>() ?? parent.Get<Bindable<RulesetInfo>>()).GetBoundCopy();
|
||||
SelectedMods = (parent.Get<LeasedBindable<IEnumerable<Mod>>>() ?? parent.Get<Bindable<IEnumerable<Mod>>>()).GetBoundCopy();
|
||||
Mods = (parent.Get<LeasedBindable<IReadOnlyList<Mod>>>() ?? parent.Get<Bindable<IReadOnlyList<Mod>>>()).GetBoundCopy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public class GameplayClockContainer : Container
|
||||
{
|
||||
private readonly IEnumerable<Mod> mods;
|
||||
private readonly WorkingBeatmap beatmap;
|
||||
private readonly IReadOnlyList<Mod> mods;
|
||||
|
||||
/// <summary>
|
||||
/// The original source (usually a <see cref="WorkingBeatmap"/>'s track).
|
||||
@ -37,6 +38,8 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
private readonly DecoupleableInterpolatingFramedClock adjustableClock;
|
||||
|
||||
private readonly double gameplayStartTime;
|
||||
|
||||
public readonly Bindable<double> UserPlaybackRate = new BindableDouble(1)
|
||||
{
|
||||
Default = 1,
|
||||
@ -53,11 +56,15 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private Bindable<double> userAudioOffset;
|
||||
|
||||
private readonly FramedOffsetClock offsetClock;
|
||||
private readonly FramedOffsetClock userOffsetClock;
|
||||
|
||||
public GameplayClockContainer(WorkingBeatmap beatmap, IEnumerable<Mod> mods, double gameplayStartTime)
|
||||
private readonly FramedOffsetClock platformOffsetClock;
|
||||
|
||||
public GameplayClockContainer(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods, double gameplayStartTime)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
this.mods = mods;
|
||||
this.gameplayStartTime = gameplayStartTime;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
@ -65,30 +72,31 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
adjustableClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
|
||||
|
||||
adjustableClock.Seek(Math.Min(0, gameplayStartTime - beatmap.BeatmapInfo.AudioLeadIn));
|
||||
|
||||
adjustableClock.ProcessFrame();
|
||||
|
||||
// Lazer's audio timings in general doesn't match stable. This is the result of user testing, albeit limited.
|
||||
// This only seems to be required on windows. We need to eventually figure out why, with a bit of luck.
|
||||
var platformOffsetClock = new FramedOffsetClock(adjustableClock) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 22 : 0 };
|
||||
platformOffsetClock = new FramedOffsetClock(adjustableClock) { Offset = RuntimeInfo.OS == RuntimeInfo.Platform.Windows ? 22 : 0 };
|
||||
|
||||
// the final usable gameplay clock with user-set offsets applied.
|
||||
offsetClock = new FramedOffsetClock(platformOffsetClock);
|
||||
userOffsetClock = new FramedOffsetClock(platformOffsetClock);
|
||||
|
||||
// the clock to be exposed via DI to children.
|
||||
GameplayClock = new GameplayClock(offsetClock);
|
||||
GameplayClock = new GameplayClock(userOffsetClock);
|
||||
|
||||
GameplayClock.IsPaused.BindTo(IsPaused);
|
||||
}
|
||||
|
||||
private double totalOffset => userOffsetClock.Offset + platformOffsetClock.Offset;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
userAudioOffset = config.GetBindable<double>(OsuSetting.AudioOffset);
|
||||
userAudioOffset.BindValueChanged(offset => offsetClock.Offset = offset.NewValue, true);
|
||||
userAudioOffset.BindValueChanged(offset => userOffsetClock.Offset = offset.NewValue, true);
|
||||
|
||||
UserPlaybackRate.ValueChanged += _ => updateRate();
|
||||
|
||||
Seek(Math.Min(0, gameplayStartTime - beatmap.BeatmapInfo.AudioLeadIn));
|
||||
adjustableClock.ProcessFrame();
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
@ -105,9 +113,7 @@ namespace osu.Game.Screens.Play
|
||||
this.Delay(750).Schedule(() =>
|
||||
{
|
||||
if (!IsPaused.Value)
|
||||
{
|
||||
adjustableClock.Start();
|
||||
}
|
||||
Start();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -122,7 +128,19 @@ namespace osu.Game.Screens.Play
|
||||
IsPaused.Value = false;
|
||||
}
|
||||
|
||||
public void Seek(double time) => adjustableClock.Seek(time);
|
||||
/// <summary>
|
||||
/// Seek to a specific time in gameplay.
|
||||
/// <remarks>
|
||||
/// Adjusts for any offsets which have been applied (so the seek may not be the expected point in time on the underlying audio track).
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
/// <param name="time">The destination time to seek to.</param>
|
||||
public void Seek(double time)
|
||||
{
|
||||
// remove the offset component here because most of the time we want the seek to be aligned to gameplay, not the audio track.
|
||||
// we may want to consider reversing the application of offsets in the future as it may feel more correct.
|
||||
adjustableClock.Seek(time - totalOffset);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
@ -139,7 +157,7 @@ namespace osu.Game.Screens.Play
|
||||
protected override void Update()
|
||||
{
|
||||
if (!IsPaused.Value)
|
||||
offsetClock.ProcessFrame();
|
||||
userOffsetClock.ProcessFrame();
|
||||
|
||||
base.Update();
|
||||
}
|
||||
|
@ -18,15 +18,15 @@ using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
public class ModDisplay : Container, IHasCurrentValue<IEnumerable<Mod>>
|
||||
public class ModDisplay : Container, IHasCurrentValue<IReadOnlyList<Mod>>
|
||||
{
|
||||
private const int fade_duration = 1000;
|
||||
|
||||
public bool DisplayUnrankedText = true;
|
||||
|
||||
private readonly Bindable<IEnumerable<Mod>> current = new Bindable<IEnumerable<Mod>>();
|
||||
private readonly Bindable<IReadOnlyList<Mod>> current = new Bindable<IReadOnlyList<Mod>>();
|
||||
|
||||
public Bindable<IEnumerable<Mod>> Current
|
||||
public Bindable<IReadOnlyList<Mod>> Current
|
||||
{
|
||||
get => current;
|
||||
set
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
public Action<double> RequestSeek;
|
||||
|
||||
public HUDOverlay(ScoreProcessor scoreProcessor, DrawableRuleset drawableRuleset, IEnumerable<Mod> mods)
|
||||
public HUDOverlay(ScoreProcessor scoreProcessor, DrawableRuleset drawableRuleset, IReadOnlyList<Mod> mods)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
|
@ -109,7 +109,7 @@ namespace osu.Game.Screens.Play
|
||||
if (!ScoreProcessor.Mode.Disabled)
|
||||
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
|
||||
|
||||
InternalChild = GameplayClockContainer = new GameplayClockContainer(working, SelectedMods.Value, DrawableRuleset.GameplayStartTime);
|
||||
InternalChild = GameplayClockContainer = new GameplayClockContainer(working, Mods.Value, DrawableRuleset.GameplayStartTime);
|
||||
|
||||
GameplayClockContainer.Children = new[]
|
||||
{
|
||||
@ -130,7 +130,7 @@ namespace osu.Game.Screens.Play
|
||||
},
|
||||
// display the cursor above some HUD elements.
|
||||
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
||||
HUDOverlay = new HUDOverlay(ScoreProcessor, DrawableRuleset, SelectedMods.Value)
|
||||
HUDOverlay = new HUDOverlay(ScoreProcessor, DrawableRuleset, Mods.Value)
|
||||
{
|
||||
HoldToQuit = { Action = performUserRequestedExit },
|
||||
PlayerSettingsOverlay = { PlaybackSettings = { UserPlaybackRate = { BindTarget = GameplayClockContainer.UserPlaybackRate } } },
|
||||
@ -177,7 +177,7 @@ namespace osu.Game.Screens.Play
|
||||
ScoreProcessor.AllJudged += onCompletion;
|
||||
ScoreProcessor.Failed += onFail;
|
||||
|
||||
foreach (var mod in SelectedMods.Value.OfType<IApplicableToScoreProcessor>())
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||
mod.ApplyToScoreProcessor(ScoreProcessor);
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
try
|
||||
{
|
||||
DrawableRuleset = rulesetInstance.CreateDrawableRulesetWith(working, SelectedMods.Value);
|
||||
DrawableRuleset = rulesetInstance.CreateDrawableRulesetWith(working, Mods.Value);
|
||||
}
|
||||
catch (BeatmapInvalidForRulesetException)
|
||||
{
|
||||
@ -207,7 +207,7 @@ namespace osu.Game.Screens.Play
|
||||
// let's try again forcing the beatmap's ruleset.
|
||||
ruleset = beatmap.BeatmapInfo.Ruleset;
|
||||
rulesetInstance = ruleset.CreateInstance();
|
||||
DrawableRuleset = rulesetInstance.CreateDrawableRulesetWith(Beatmap.Value, SelectedMods.Value);
|
||||
DrawableRuleset = rulesetInstance.CreateDrawableRulesetWith(Beatmap.Value, Mods.Value);
|
||||
}
|
||||
|
||||
if (!DrawableRuleset.Objects.Any())
|
||||
@ -278,7 +278,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
Beatmap = Beatmap.Value.BeatmapInfo,
|
||||
Ruleset = ruleset,
|
||||
Mods = SelectedMods.Value.ToArray(),
|
||||
Mods = Mods.Value.ToArray(),
|
||||
User = api.LocalUser.Value,
|
||||
};
|
||||
|
||||
@ -332,7 +332,7 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private bool onFail()
|
||||
{
|
||||
if (SelectedMods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail))
|
||||
if (Mods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail))
|
||||
return false;
|
||||
|
||||
GameplayClockContainer.Stop();
|
||||
|
@ -68,7 +68,7 @@ namespace osu.Game.Screens.Play
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
info = new BeatmapMetadataDisplay(Beatmap.Value, SelectedMods.Value)
|
||||
info = new BeatmapMetadataDisplay(Beatmap.Value, Mods.Value)
|
||||
{
|
||||
Alpha = 0,
|
||||
Anchor = Anchor.Centre,
|
||||
@ -301,7 +301,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
|
||||
private readonly WorkingBeatmap beatmap;
|
||||
private readonly IEnumerable<Mod> mods;
|
||||
private readonly IReadOnlyList<Mod> mods;
|
||||
private LoadingAnimation loading;
|
||||
private Sprite backgroundSprite;
|
||||
private ModDisplay modDisplay;
|
||||
@ -323,7 +323,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
|
||||
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, IEnumerable<Mod> mods)
|
||||
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
this.mods = mods;
|
||||
|
@ -310,12 +310,12 @@ namespace osu.Game.Screens.Select
|
||||
try
|
||||
{
|
||||
// Try to get the beatmap with the user's ruleset
|
||||
playableBeatmap = beatmap.GetPlayableBeatmap(ruleset, Enumerable.Empty<Mod>());
|
||||
playableBeatmap = beatmap.GetPlayableBeatmap(ruleset, Array.Empty<Mod>());
|
||||
}
|
||||
catch (BeatmapInvalidForRulesetException)
|
||||
{
|
||||
// Can't be converted to the user's ruleset, so use the beatmap's own ruleset
|
||||
playableBeatmap = beatmap.GetPlayableBeatmap(beatmap.BeatmapInfo.Ruleset, Enumerable.Empty<Mod>());
|
||||
playableBeatmap = beatmap.GetPlayableBeatmap(beatmap.BeatmapInfo.Ruleset, Array.Empty<Mod>());
|
||||
}
|
||||
|
||||
labels.AddRange(playableBeatmap.GetStatistics().Select(s => new InfoLabel(s)));
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Humanizer;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -42,7 +41,7 @@ namespace osu.Game.Screens.Select
|
||||
RulesetID = Ruleset.Value.ID ?? 0
|
||||
};
|
||||
|
||||
item.RequiredMods.AddRange(SelectedMods.Value);
|
||||
item.RequiredMods.AddRange(Mods.Value);
|
||||
|
||||
Selected?.Invoke(item);
|
||||
|
||||
@ -61,12 +60,12 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
Ruleset.Value = CurrentItem.Value.Ruleset;
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(CurrentItem.Value.Beatmap);
|
||||
SelectedMods.Value = CurrentItem.Value.RequiredMods ?? Enumerable.Empty<Mod>();
|
||||
Mods.Value = CurrentItem.Value.RequiredMods?.ToArray() ?? Array.Empty<Mod>();
|
||||
}
|
||||
|
||||
Beatmap.Disabled = true;
|
||||
Ruleset.Disabled = true;
|
||||
SelectedMods.Disabled = true;
|
||||
Mods.Disabled = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -77,7 +76,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
Beatmap.Disabled = false;
|
||||
Ruleset.Disabled = false;
|
||||
SelectedMods.Disabled = false;
|
||||
Mods.Disabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,10 +52,10 @@ namespace osu.Game.Screens.Select
|
||||
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
|
||||
var autoType = auto.GetType();
|
||||
|
||||
var mods = SelectedMods.Value;
|
||||
var mods = Mods.Value;
|
||||
if (mods.All(m => m.GetType() != autoType))
|
||||
{
|
||||
SelectedMods.Value = mods.Append(auto);
|
||||
Mods.Value = mods.Append(auto).ToArray();
|
||||
removeAutoModOnResume = true;
|
||||
}
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ namespace osu.Game.Screens.Select
|
||||
private readonly Bindable<RulesetInfo> decoupledRuleset = new Bindable<RulesetInfo>();
|
||||
|
||||
[Cached]
|
||||
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
||||
private readonly Bindable<IEnumerable<Mod>> selectedMods = new Bindable<IEnumerable<Mod>>(Enumerable.Empty<Mod>()); // Bound to the game's mods, but is not reset on exiting
|
||||
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
||||
private readonly Bindable<IReadOnlyList<Mod>> mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>()); // Bound to the game's mods, but is not reset on exiting
|
||||
|
||||
protected SongSelect()
|
||||
{
|
||||
@ -219,7 +219,7 @@ namespace osu.Game.Screens.Select
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins)
|
||||
{
|
||||
selectedMods.BindTo(SelectedMods);
|
||||
mods.BindTo(Mods);
|
||||
|
||||
if (Footer != null)
|
||||
{
|
||||
@ -394,7 +394,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
Logger.Log($"ruleset changed from \"{decoupledRuleset.Value}\" to \"{ruleset}\"");
|
||||
|
||||
selectedMods.Value = Enumerable.Empty<Mod>();
|
||||
mods.Value = Array.Empty<Mod>();
|
||||
decoupledRuleset.Value = ruleset;
|
||||
|
||||
// force a filter before attempting to change the beatmap.
|
||||
@ -529,8 +529,8 @@ namespace osu.Game.Screens.Select
|
||||
if (Beatmap.Value.Track != null)
|
||||
Beatmap.Value.Track.Looping = false;
|
||||
|
||||
selectedMods.UnbindAll();
|
||||
SelectedMods.Value = Enumerable.Empty<Mod>();
|
||||
mods.UnbindAll();
|
||||
Mods.Value = Array.Empty<Mod>();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace osu.Game.Tests.Visual
|
||||
var working = CreateWorkingBeatmap(beatmap, Clock);
|
||||
|
||||
Beatmap.Value = working;
|
||||
SelectedMods.Value = new[] { r.GetAllMods().First(m => m is ModNoFail) };
|
||||
Mods.Value = new[] { r.GetAllMods().First(m => m is ModNoFail) };
|
||||
|
||||
Player?.Exit();
|
||||
Player = null;
|
||||
|
@ -28,8 +28,8 @@ namespace osu.Game.Tests.Visual
|
||||
protected readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
[Cached]
|
||||
[Cached(Type = typeof(IBindable<IEnumerable<Mod>>))]
|
||||
protected readonly Bindable<IEnumerable<Mod>> SelectedMods = new Bindable<IEnumerable<Mod>>(Enumerable.Empty<Mod>());
|
||||
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
|
||||
protected readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
protected DependencyContainer Dependencies { get; private set; }
|
||||
|
||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Tests.Visual
|
||||
Beatmap.Value = new TestWorkingBeatmap(beatmap, Clock);
|
||||
|
||||
if (!AllowFail)
|
||||
SelectedMods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
|
||||
Mods.Value = new[] { ruleset.GetAllMods().First(m => m is ModNoFail) };
|
||||
|
||||
Player = CreatePlayer(ruleset);
|
||||
LoadScreen(Player);
|
||||
|
Loading…
Reference in New Issue
Block a user