mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 05:32:54 +08:00
Merge branch 'master' into remove-dispose-updates
This commit is contained in:
commit
6a35b233e5
@ -77,5 +77,8 @@ namespace osu.Game.Rulesets.EmptyFreeform
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Leave this line intact. It will bake the correct version into the ruleset on each build/release.
|
||||||
|
public override string RulesetAPIVersionSupported => CURRENT_RULESET_API_VERSION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,5 +49,8 @@ namespace osu.Game.Rulesets.Pippidon
|
|||||||
};
|
};
|
||||||
|
|
||||||
public override Drawable CreateIcon() => new PippidonRulesetIcon(this);
|
public override Drawable CreateIcon() => new PippidonRulesetIcon(this);
|
||||||
|
|
||||||
|
// Leave this line intact. It will bake the correct version into the ruleset on each build/release.
|
||||||
|
public override string RulesetAPIVersionSupported => CURRENT_RULESET_API_VERSION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,5 +54,8 @@ namespace osu.Game.Rulesets.EmptyScrolling
|
|||||||
Text = ShortName[0].ToString(),
|
Text = ShortName[0].ToString(),
|
||||||
Font = OsuFont.Default.With(size: 18),
|
Font = OsuFont.Default.With(size: 18),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Leave this line intact. It will bake the correct version into the ruleset on each build/release.
|
||||||
|
public override string RulesetAPIVersionSupported => CURRENT_RULESET_API_VERSION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,5 +46,8 @@ namespace osu.Game.Rulesets.Pippidon
|
|||||||
};
|
};
|
||||||
|
|
||||||
public override Drawable CreateIcon() => new PippidonRulesetIcon(this);
|
public override Drawable CreateIcon() => new PippidonRulesetIcon(this);
|
||||||
|
|
||||||
|
// Leave this line intact. It will bake the correct version into the ruleset on each build/release.
|
||||||
|
public override string RulesetAPIVersionSupported => CURRENT_RULESET_API_VERSION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
<Reference Include="Java.Interop" />
|
<Reference Include="Java.Interop" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.819.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.831.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.825.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.825.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Transitive Dependencies">
|
<ItemGroup Label="Transitive Dependencies">
|
||||||
|
@ -76,7 +76,7 @@ namespace osu.Desktop.Security
|
|||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.ShieldAlt;
|
Icon = FontAwesome.Solid.ShieldAlt;
|
||||||
IconBackground.Colour = colours.YellowDark;
|
IconContent.Colour = colours.YellowDark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,10 +70,17 @@ namespace osu.Game.Rulesets.Catch.Tests.Editor
|
|||||||
[Cached]
|
[Cached]
|
||||||
private readonly BindableBeatDivisor beatDivisor;
|
private readonly BindableBeatDivisor beatDivisor;
|
||||||
|
|
||||||
|
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
public EditorBeatmapDependencyContainer(IBeatmap beatmap, BindableBeatDivisor beatDivisor)
|
public EditorBeatmapDependencyContainer(IBeatmap beatmap, BindableBeatDivisor beatDivisor)
|
||||||
{
|
{
|
||||||
editorClock = new EditorClock(beatmap, beatDivisor);
|
|
||||||
this.beatDivisor = beatDivisor;
|
this.beatDivisor = beatDivisor;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
editorClock = new EditorClock(beatmap, beatDivisor),
|
||||||
|
Content,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,30 +3,30 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using System;
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Rulesets.Catch.Mods;
|
|
||||||
using osu.Game.Rulesets.Catch.UI;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Extensions.EnumExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Rulesets.Catch.Replays;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Rulesets.Replays.Types;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Legacy;
|
using osu.Game.Beatmaps.Legacy;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Catch.Beatmaps;
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.Difficulty;
|
using osu.Game.Rulesets.Catch.Difficulty;
|
||||||
using osu.Game.Rulesets.Catch.Scoring;
|
|
||||||
using osu.Game.Rulesets.Difficulty;
|
|
||||||
using osu.Game.Rulesets.Scoring;
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Extensions.EnumExtensions;
|
|
||||||
using osu.Framework.Localisation;
|
|
||||||
using osu.Game.Rulesets.Catch.Edit;
|
using osu.Game.Rulesets.Catch.Edit;
|
||||||
|
using osu.Game.Rulesets.Catch.Mods;
|
||||||
|
using osu.Game.Rulesets.Catch.Replays;
|
||||||
|
using osu.Game.Rulesets.Catch.Scoring;
|
||||||
using osu.Game.Rulesets.Catch.Skinning.Legacy;
|
using osu.Game.Rulesets.Catch.Skinning.Legacy;
|
||||||
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.Difficulty;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Replays.Types;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch
|
namespace osu.Game.Rulesets.Catch
|
||||||
@ -43,6 +43,8 @@ namespace osu.Game.Rulesets.Catch
|
|||||||
|
|
||||||
public const string SHORT_NAME = "fruits";
|
public const string SHORT_NAME = "fruits";
|
||||||
|
|
||||||
|
public override string RulesetAPIVersionSupported => CURRENT_RULESET_API_VERSION;
|
||||||
|
|
||||||
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
||||||
{
|
{
|
||||||
new KeyBinding(InputKey.Z, CatchAction.MoveLeft),
|
new KeyBinding(InputKey.Z, CatchAction.MoveLeft),
|
||||||
|
@ -10,6 +10,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
@ -34,10 +35,14 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
|||||||
{
|
{
|
||||||
AddStep("setup compose screen", () =>
|
AddStep("setup compose screen", () =>
|
||||||
{
|
{
|
||||||
var editorBeatmap = new EditorBeatmap(new ManiaBeatmap(new StageDefinition { Columns = 4 })
|
var beatmap = new ManiaBeatmap(new StageDefinition { Columns = 4 })
|
||||||
{
|
{
|
||||||
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
|
BeatmapInfo = { Ruleset = new ManiaRuleset().RulesetInfo },
|
||||||
});
|
};
|
||||||
|
|
||||||
|
beatmap.ControlPointInfo.Add(0, new TimingControlPoint());
|
||||||
|
|
||||||
|
var editorBeatmap = new EditorBeatmap(beatmap, new LegacyBeatmapSkin(beatmap.BeatmapInfo, null));
|
||||||
|
|
||||||
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
|
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
|
||||||
|
|
||||||
@ -50,7 +55,11 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
|||||||
(typeof(IBeatSnapProvider), editorBeatmap),
|
(typeof(IBeatSnapProvider), editorBeatmap),
|
||||||
(typeof(OverlayColourProvider), new OverlayColourProvider(OverlayColourScheme.Green)),
|
(typeof(OverlayColourProvider), new OverlayColourProvider(OverlayColourScheme.Green)),
|
||||||
},
|
},
|
||||||
Child = new ComposeScreen { State = { Value = Visibility.Visible } },
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
editorBeatmap,
|
||||||
|
new ComposeScreen { State = { Value = Visibility.Visible } },
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
|||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
BeatDivisor.Value = 8;
|
BeatDivisor.Value = 8;
|
||||||
Clock.Seek(0);
|
EditorClock.Seek(0);
|
||||||
|
|
||||||
Child = composer = new TestComposer { RelativeSizeAxes = Axes.Both };
|
Child = composer = new TestComposer { RelativeSizeAxes = Axes.Both };
|
||||||
});
|
});
|
||||||
@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
|||||||
{
|
{
|
||||||
lastObject = this.ChildrenOfType<DrawableHitObject>().Single(d => d.HitObject == composer.EditorBeatmap.HitObjects.Last());
|
lastObject = this.ChildrenOfType<DrawableHitObject>().Single(d => d.HitObject == composer.EditorBeatmap.HitObjects.Last());
|
||||||
originalTime = lastObject.HitObject.StartTime;
|
originalTime = lastObject.HitObject.StartTime;
|
||||||
Clock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
EditorClock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("select all objects", () => composer.EditorBeatmap.SelectedHitObjects.AddRange(composer.EditorBeatmap.HitObjects));
|
AddStep("select all objects", () => composer.EditorBeatmap.SelectedHitObjects.AddRange(composer.EditorBeatmap.HitObjects));
|
||||||
@ -90,7 +90,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
|||||||
{
|
{
|
||||||
lastObject = this.ChildrenOfType<DrawableHitObject>().Single(d => d.HitObject == composer.EditorBeatmap.HitObjects.Last());
|
lastObject = this.ChildrenOfType<DrawableHitObject>().Single(d => d.HitObject == composer.EditorBeatmap.HitObjects.Last());
|
||||||
originalTime = lastObject.HitObject.StartTime;
|
originalTime = lastObject.HitObject.StartTime;
|
||||||
Clock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
EditorClock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("select all objects", () => composer.EditorBeatmap.SelectedHitObjects.AddRange(composer.EditorBeatmap.HitObjects));
|
AddStep("select all objects", () => composer.EditorBeatmap.SelectedHitObjects.AddRange(composer.EditorBeatmap.HitObjects));
|
||||||
@ -125,7 +125,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
|||||||
AddStep("seek to last object", () =>
|
AddStep("seek to last object", () =>
|
||||||
{
|
{
|
||||||
lastObject = this.ChildrenOfType<DrawableHitObject>().Single(d => d.HitObject == composer.EditorBeatmap.HitObjects.Last());
|
lastObject = this.ChildrenOfType<DrawableHitObject>().Single(d => d.HitObject == composer.EditorBeatmap.HitObjects.Last());
|
||||||
Clock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
EditorClock.Seek(composer.EditorBeatmap.HitObjects.Last().StartTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("select all objects", () => composer.EditorBeatmap.SelectedHitObjects.AddRange(composer.EditorBeatmap.HitObjects));
|
AddStep("select all objects", () => composer.EditorBeatmap.SelectedHitObjects.AddRange(composer.EditorBeatmap.HitObjects));
|
||||||
|
@ -4,11 +4,6 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Rulesets.Mania.Mods;
|
|
||||||
using osu.Game.Rulesets.Mania.UI;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Extensions.EnumExtensions;
|
using osu.Framework.Extensions.EnumExtensions;
|
||||||
@ -16,11 +11,10 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Replays;
|
|
||||||
using osu.Game.Rulesets.Replays.Types;
|
|
||||||
using osu.Game.Beatmaps.Legacy;
|
using osu.Game.Beatmaps.Legacy;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Rulesets.Configuration;
|
using osu.Game.Rulesets.Configuration;
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
@ -31,13 +25,19 @@ using osu.Game.Rulesets.Mania.Configuration;
|
|||||||
using osu.Game.Rulesets.Mania.Difficulty;
|
using osu.Game.Rulesets.Mania.Difficulty;
|
||||||
using osu.Game.Rulesets.Mania.Edit;
|
using osu.Game.Rulesets.Mania.Edit;
|
||||||
using osu.Game.Rulesets.Mania.Edit.Setup;
|
using osu.Game.Rulesets.Mania.Edit.Setup;
|
||||||
|
using osu.Game.Rulesets.Mania.Mods;
|
||||||
|
using osu.Game.Rulesets.Mania.Replays;
|
||||||
using osu.Game.Rulesets.Mania.Scoring;
|
using osu.Game.Rulesets.Mania.Scoring;
|
||||||
using osu.Game.Rulesets.Mania.Skinning.Legacy;
|
using osu.Game.Rulesets.Mania.Skinning.Legacy;
|
||||||
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Replays.Types;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Edit.Setup;
|
using osu.Game.Screens.Edit.Setup;
|
||||||
using osu.Game.Screens.Ranking.Statistics;
|
using osu.Game.Screens.Ranking.Statistics;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania
|
namespace osu.Game.Rulesets.Mania
|
||||||
{
|
{
|
||||||
@ -60,6 +60,8 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
|
|
||||||
public const string SHORT_NAME = "mania";
|
public const string SHORT_NAME = "mania";
|
||||||
|
|
||||||
|
public override string RulesetAPIVersionSupported => CURRENT_RULESET_API_VERSION;
|
||||||
|
|
||||||
public override HitObjectComposer CreateHitObjectComposer() => new ManiaHitObjectComposer(this);
|
public override HitObjectComposer CreateHitObjectComposer() => new ManiaHitObjectComposer(this);
|
||||||
|
|
||||||
public override ISkin CreateLegacySkinProvider(ISkin skin, IBeatmap beatmap) => new ManiaLegacySkinTransformer(skin, beatmap);
|
public override ISkin CreateLegacySkinProvider(ISkin skin, IBeatmap beatmap) => new ManiaLegacySkinTransformer(skin, beatmap);
|
||||||
|
@ -3,9 +3,11 @@
|
|||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Osu.Edit;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -14,6 +16,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
{
|
{
|
||||||
public class TestSceneObjectMerging : TestSceneOsuEditor
|
public class TestSceneObjectMerging : TestSceneOsuEditor
|
||||||
{
|
{
|
||||||
|
private OsuSelectionHandler selectionHandler => Editor.ChildrenOfType<OsuSelectionHandler>().First();
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSimpleMerge()
|
public void TestSimpleMerge()
|
||||||
{
|
{
|
||||||
@ -29,6 +33,9 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
EditorBeatmap.SelectedHitObjects.Add(circle2);
|
EditorBeatmap.SelectedHitObjects.Add(circle2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
moveMouseToHitObject(1);
|
||||||
|
AddAssert("merge option available", () => selectionHandler.ContextMenuItems.Any(o => o.Text.Value == "Merge selection"));
|
||||||
|
|
||||||
mergeSelection();
|
mergeSelection();
|
||||||
|
|
||||||
AddAssert("slider created", () => circle1 is not null && circle2 is not null && sliderCreatedFor(
|
AddAssert("slider created", () => circle1 is not null && circle2 is not null && sliderCreatedFor(
|
||||||
@ -174,6 +181,57 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
AddAssert("spinner not merged", () => EditorBeatmap.HitObjects.Contains(spinner));
|
AddAssert("spinner not merged", () => EditorBeatmap.HitObjects.Contains(spinner));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestIllegalMerge()
|
||||||
|
{
|
||||||
|
HitCircle? circle1 = null;
|
||||||
|
HitCircle? circle2 = null;
|
||||||
|
|
||||||
|
AddStep("add two circles on the same position", () =>
|
||||||
|
{
|
||||||
|
circle1 = new HitCircle();
|
||||||
|
circle2 = new HitCircle { Position = circle1.Position + Vector2.UnitX };
|
||||||
|
EditorClock.Seek(0);
|
||||||
|
EditorBeatmap.Add(circle1);
|
||||||
|
EditorBeatmap.Add(circle2);
|
||||||
|
EditorBeatmap.SelectedHitObjects.Add(circle1);
|
||||||
|
EditorBeatmap.SelectedHitObjects.Add(circle2);
|
||||||
|
});
|
||||||
|
|
||||||
|
moveMouseToHitObject(1);
|
||||||
|
AddAssert("merge option not available", () => selectionHandler.ContextMenuItems.Length > 0 && selectionHandler.ContextMenuItems.All(o => o.Text.Value != "Merge selection"));
|
||||||
|
mergeSelection();
|
||||||
|
AddAssert("circles not merged", () => circle1 is not null && circle2 is not null
|
||||||
|
&& EditorBeatmap.HitObjects.Contains(circle1) && EditorBeatmap.HitObjects.Contains(circle2));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSameStartTimeMerge()
|
||||||
|
{
|
||||||
|
HitCircle? circle1 = null;
|
||||||
|
HitCircle? circle2 = null;
|
||||||
|
|
||||||
|
AddStep("add two circles at the same time", () =>
|
||||||
|
{
|
||||||
|
circle1 = new HitCircle();
|
||||||
|
circle2 = new HitCircle { Position = circle1.Position + 100 * Vector2.UnitX };
|
||||||
|
EditorClock.Seek(0);
|
||||||
|
EditorBeatmap.Add(circle1);
|
||||||
|
EditorBeatmap.Add(circle2);
|
||||||
|
EditorBeatmap.SelectedHitObjects.Add(circle1);
|
||||||
|
EditorBeatmap.SelectedHitObjects.Add(circle2);
|
||||||
|
});
|
||||||
|
|
||||||
|
moveMouseToHitObject(1);
|
||||||
|
AddAssert("merge option available", () => selectionHandler.ContextMenuItems.Any(o => o.Text.Value == "Merge selection"));
|
||||||
|
|
||||||
|
mergeSelection();
|
||||||
|
|
||||||
|
AddAssert("slider created", () => circle1 is not null && circle2 is not null && sliderCreatedFor(
|
||||||
|
(pos: circle1.Position, pathType: PathType.Linear),
|
||||||
|
(pos: circle2.Position, pathType: null)));
|
||||||
|
}
|
||||||
|
|
||||||
private void mergeSelection()
|
private void mergeSelection()
|
||||||
{
|
{
|
||||||
AddStep("merge selection", () =>
|
AddStep("merge selection", () =>
|
||||||
@ -225,5 +283,17 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
|
|
||||||
return mergedSlider.Samples[0] is not null;
|
return mergedSlider.Samples[0] is not null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void moveMouseToHitObject(int index)
|
||||||
|
{
|
||||||
|
AddStep($"hover mouse over hit object {index}", () =>
|
||||||
|
{
|
||||||
|
if (EditorBeatmap.HitObjects.Count <= index)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Vector2 position = ((OsuHitObject)EditorBeatmap.HitObjects[index]).Position;
|
||||||
|
InputManager.MoveMouseTo(selectionHandler.ToScreenSpace(position));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,10 +59,9 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
editorClock = new EditorClock(editorBeatmap);
|
|
||||||
|
|
||||||
base.Content.Children = new Drawable[]
|
base.Content.Children = new Drawable[]
|
||||||
{
|
{
|
||||||
|
editorClock = new EditorClock(editorBeatmap),
|
||||||
snapProvider,
|
snapProvider,
|
||||||
Content
|
Content
|
||||||
};
|
};
|
||||||
|
@ -18,11 +18,14 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
|||||||
private const double min_velocity = 0.5;
|
private const double min_velocity = 0.5;
|
||||||
private const double slider_multiplier = 1.3;
|
private const double slider_multiplier = 1.3;
|
||||||
|
|
||||||
|
private const double min_angle_multiplier = 0.2;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Evaluates the difficulty of memorising and hitting an object, based on:
|
/// Evaluates the difficulty of memorising and hitting an object, based on:
|
||||||
/// <list type="bullet">
|
/// <list type="bullet">
|
||||||
/// <item><description>distance between a number of previous objects and the current object,</description></item>
|
/// <item><description>distance between a number of previous objects and the current object,</description></item>
|
||||||
/// <item><description>the visual opacity of the current object,</description></item>
|
/// <item><description>the visual opacity of the current object,</description></item>
|
||||||
|
/// <item><description>the angle made by the current object,</description></item>
|
||||||
/// <item><description>length and speed of the current object (for sliders),</description></item>
|
/// <item><description>length and speed of the current object (for sliders),</description></item>
|
||||||
/// <item><description>and whether the hidden mod is enabled.</description></item>
|
/// <item><description>and whether the hidden mod is enabled.</description></item>
|
||||||
/// </list>
|
/// </list>
|
||||||
@ -43,6 +46,8 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
|||||||
|
|
||||||
OsuDifficultyHitObject lastObj = osuCurrent;
|
OsuDifficultyHitObject lastObj = osuCurrent;
|
||||||
|
|
||||||
|
double angleRepeatCount = 0.0;
|
||||||
|
|
||||||
// This is iterating backwards in time from the current object.
|
// This is iterating backwards in time from the current object.
|
||||||
for (int i = 0; i < Math.Min(current.Index, 10); i++)
|
for (int i = 0; i < Math.Min(current.Index, 10); i++)
|
||||||
{
|
{
|
||||||
@ -66,6 +71,13 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
|||||||
double opacityBonus = 1.0 + max_opacity_bonus * (1.0 - osuCurrent.OpacityAt(currentHitObject.StartTime, hidden));
|
double opacityBonus = 1.0 + max_opacity_bonus * (1.0 - osuCurrent.OpacityAt(currentHitObject.StartTime, hidden));
|
||||||
|
|
||||||
result += stackNerf * opacityBonus * scalingFactor * jumpDistance / cumulativeStrainTime;
|
result += stackNerf * opacityBonus * scalingFactor * jumpDistance / cumulativeStrainTime;
|
||||||
|
|
||||||
|
if (currentObj.Angle != null && osuCurrent.Angle != null)
|
||||||
|
{
|
||||||
|
// Objects further back in time should count less for the nerf.
|
||||||
|
if (Math.Abs(currentObj.Angle.Value - osuCurrent.Angle.Value) < 0.02)
|
||||||
|
angleRepeatCount += Math.Max(1.0 - 0.1 * i, 0.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lastObj = currentObj;
|
lastObj = currentObj;
|
||||||
@ -77,6 +89,9 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
|
|||||||
if (hidden)
|
if (hidden)
|
||||||
result *= 1.0 + hidden_bonus;
|
result *= 1.0 + hidden_bonus;
|
||||||
|
|
||||||
|
// Nerf patterns with repeated angles.
|
||||||
|
result *= min_angle_multiplier + (1.0 - min_angle_multiplier) / (angleRepeatCount + 1.0);
|
||||||
|
|
||||||
double sliderBonus = 0.0;
|
double sliderBonus = 0.0;
|
||||||
|
|
||||||
if (osuCurrent.BaseObject is Slider osuSlider)
|
if (osuCurrent.BaseObject is Slider osuSlider)
|
||||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
|||||||
hasHiddenMod = mods.Any(m => m is OsuModHidden);
|
hasHiddenMod = mods.Any(m => m is OsuModHidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double skillMultiplier => 0.05;
|
private double skillMultiplier => 0.052;
|
||||||
private double strainDecayBase => 0.15;
|
private double strainDecayBase => 0.15;
|
||||||
|
|
||||||
private double currentStrain;
|
private double currentStrain;
|
||||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
|||||||
if (maxStrain == 0)
|
if (maxStrain == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return objectStrains.Aggregate((total, next) => total + (1.0 / (1.0 + Math.Exp(-(next / maxStrain * 12.0 - 6.0)))));
|
return objectStrains.Sum(strain => 1.0 / (1.0 + Math.Exp(-(strain / maxStrain * 12.0 - 6.0))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,10 +358,10 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
{
|
{
|
||||||
var mergeableObjects = selectedMergeableObjects;
|
var mergeableObjects = selectedMergeableObjects;
|
||||||
|
|
||||||
if (mergeableObjects.Length < 2)
|
if (!canMerge(mergeableObjects))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ChangeHandler?.BeginChange();
|
EditorBeatmap.BeginChange();
|
||||||
|
|
||||||
// Have an initial slider object.
|
// Have an initial slider object.
|
||||||
var firstHitObject = mergeableObjects[0];
|
var firstHitObject = mergeableObjects[0];
|
||||||
@ -437,7 +437,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
SelectedItems.Clear();
|
SelectedItems.Clear();
|
||||||
SelectedItems.Add(mergedHitObject);
|
SelectedItems.Add(mergedHitObject);
|
||||||
|
|
||||||
ChangeHandler?.EndChange();
|
EditorBeatmap.EndChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<HitObject>> selection)
|
protected override IEnumerable<MenuItem> GetContextMenuItemsForSelection(IEnumerable<SelectionBlueprint<HitObject>> selection)
|
||||||
@ -445,8 +445,13 @@ namespace osu.Game.Rulesets.Osu.Edit
|
|||||||
foreach (var item in base.GetContextMenuItemsForSelection(selection))
|
foreach (var item in base.GetContextMenuItemsForSelection(selection))
|
||||||
yield return item;
|
yield return item;
|
||||||
|
|
||||||
if (selectedMergeableObjects.Length > 1)
|
if (canMerge(selectedMergeableObjects))
|
||||||
yield return new OsuMenuItem("Merge selection", MenuItemType.Destructive, mergeSelection);
|
yield return new OsuMenuItem("Merge selection", MenuItemType.Destructive, mergeSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool canMerge(IReadOnlyList<OsuHitObject> objects) =>
|
||||||
|
objects.Count > 1
|
||||||
|
&& (objects.Any(h => h is Slider)
|
||||||
|
|| objects.Zip(objects.Skip(1), (h1, h2) => Precision.DefinitelyBigger(Vector2.DistanceSquared(h1.Position, h2.Position), 1)).Any(x => x));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,9 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
Value = null
|
Value = null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[SettingSource("Metronome ticks", "Whether a metronome beat should play in the background")]
|
||||||
|
public Bindable<bool> Metronome { get; } = new BindableBool(true);
|
||||||
|
|
||||||
#region Constants
|
#region Constants
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -337,7 +340,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
||||||
{
|
{
|
||||||
drawableRuleset.Overlays.Add(new MetronomeBeat(drawableRuleset.Beatmap.HitObjects.First().StartTime));
|
if (Metronome.Value)
|
||||||
|
drawableRuleset.Overlays.Add(new MetronomeBeat(drawableRuleset.Beatmap.HitObjects.First().StartTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Caching;
|
|||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Beatmaps.Formats;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Osu.Judgements;
|
using osu.Game.Rulesets.Osu.Judgements;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -165,11 +166,15 @@ namespace osu.Game.Rulesets.Osu.Objects
|
|||||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||||
|
|
||||||
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
||||||
|
#pragma warning disable 618
|
||||||
|
var legacyDifficultyPoint = DifficultyControlPoint as LegacyBeatmapDecoder.LegacyDifficultyControlPoint;
|
||||||
|
#pragma warning restore 618
|
||||||
|
|
||||||
double scoringDistance = BASE_SCORING_DISTANCE * difficulty.SliderMultiplier * DifficultyControlPoint.SliderVelocity;
|
double scoringDistance = BASE_SCORING_DISTANCE * difficulty.SliderMultiplier * DifficultyControlPoint.SliderVelocity;
|
||||||
|
bool generateTicks = legacyDifficultyPoint?.GenerateTicks ?? true;
|
||||||
|
|
||||||
Velocity = scoringDistance / timingPoint.BeatLength;
|
Velocity = scoringDistance / timingPoint.BeatLength;
|
||||||
TickDistance = scoringDistance / difficulty.SliderTickRate * TickDistanceMultiplier;
|
TickDistance = generateTicks ? (scoringDistance / difficulty.SliderTickRate * TickDistanceMultiplier) : double.PositiveInfinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
||||||
|
@ -3,42 +3,42 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using System;
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Extensions.EnumExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Overlays.Settings;
|
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Rulesets.Osu.Edit;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Replays;
|
|
||||||
using osu.Game.Rulesets.Replays.Types;
|
|
||||||
using osu.Game.Beatmaps.Legacy;
|
using osu.Game.Beatmaps.Legacy;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Rulesets.Configuration;
|
using osu.Game.Rulesets.Configuration;
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Beatmaps;
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
using osu.Game.Rulesets.Osu.Configuration;
|
using osu.Game.Rulesets.Osu.Configuration;
|
||||||
using osu.Game.Rulesets.Osu.Difficulty;
|
using osu.Game.Rulesets.Osu.Difficulty;
|
||||||
using osu.Game.Rulesets.Osu.Scoring;
|
using osu.Game.Rulesets.Osu.Edit;
|
||||||
using osu.Game.Rulesets.Scoring;
|
|
||||||
using osu.Game.Scoring;
|
|
||||||
using osu.Game.Skinning;
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Extensions.EnumExtensions;
|
|
||||||
using osu.Framework.Localisation;
|
|
||||||
using osu.Game.Rulesets.Osu.Edit.Setup;
|
using osu.Game.Rulesets.Osu.Edit.Setup;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Rulesets.Osu.Replays;
|
||||||
|
using osu.Game.Rulesets.Osu.Scoring;
|
||||||
using osu.Game.Rulesets.Osu.Skinning.Legacy;
|
using osu.Game.Rulesets.Osu.Skinning.Legacy;
|
||||||
using osu.Game.Rulesets.Osu.Statistics;
|
using osu.Game.Rulesets.Osu.Statistics;
|
||||||
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
|
using osu.Game.Rulesets.Replays.Types;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Edit.Setup;
|
using osu.Game.Screens.Edit.Setup;
|
||||||
using osu.Game.Screens.Ranking.Statistics;
|
using osu.Game.Screens.Ranking.Statistics;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu
|
namespace osu.Game.Rulesets.Osu
|
||||||
{
|
{
|
||||||
@ -54,6 +54,8 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
|
|
||||||
public const string SHORT_NAME = "osu";
|
public const string SHORT_NAME = "osu";
|
||||||
|
|
||||||
|
public override string RulesetAPIVersionSupported => CURRENT_RULESET_API_VERSION;
|
||||||
|
|
||||||
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
||||||
{
|
{
|
||||||
new KeyBinding(InputKey.Z, OsuAction.LeftButton),
|
new KeyBinding(InputKey.Z, OsuAction.LeftButton),
|
||||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Editor
|
|||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
BeatDivisor.Value = 8;
|
BeatDivisor.Value = 8;
|
||||||
Clock.Seek(0);
|
EditorClock.Seek(0);
|
||||||
|
|
||||||
Child = new TestComposer { RelativeSizeAxes = Axes.Both };
|
Child = new TestComposer { RelativeSizeAxes = Axes.Both };
|
||||||
});
|
});
|
||||||
|
@ -3,33 +3,33 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using System;
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Rulesets.Taiko.Mods;
|
|
||||||
using osu.Game.Rulesets.Taiko.UI;
|
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Extensions.EnumExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Rulesets.Replays.Types;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Rulesets.Taiko.Replays;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Legacy;
|
using osu.Game.Beatmaps.Legacy;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Difficulty;
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Replays.Types;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.Taiko.Beatmaps;
|
using osu.Game.Rulesets.Taiko.Beatmaps;
|
||||||
using osu.Game.Rulesets.Taiko.Difficulty;
|
using osu.Game.Rulesets.Taiko.Difficulty;
|
||||||
using osu.Game.Rulesets.Taiko.Scoring;
|
|
||||||
using osu.Game.Scoring;
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Extensions.EnumExtensions;
|
|
||||||
using osu.Framework.Localisation;
|
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Taiko.Edit;
|
using osu.Game.Rulesets.Taiko.Edit;
|
||||||
|
using osu.Game.Rulesets.Taiko.Mods;
|
||||||
using osu.Game.Rulesets.Taiko.Objects;
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
|
using osu.Game.Rulesets.Taiko.Replays;
|
||||||
|
using osu.Game.Rulesets.Taiko.Scoring;
|
||||||
using osu.Game.Rulesets.Taiko.Skinning.Legacy;
|
using osu.Game.Rulesets.Taiko.Skinning.Legacy;
|
||||||
|
using osu.Game.Rulesets.Taiko.UI;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Ranking.Statistics;
|
using osu.Game.Screens.Ranking.Statistics;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
@ -49,6 +49,8 @@ namespace osu.Game.Rulesets.Taiko
|
|||||||
|
|
||||||
public const string SHORT_NAME = "taiko";
|
public const string SHORT_NAME = "taiko";
|
||||||
|
|
||||||
|
public override string RulesetAPIVersionSupported => CURRENT_RULESET_API_VERSION;
|
||||||
|
|
||||||
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
|
||||||
{
|
{
|
||||||
new KeyBinding(InputKey.MouseLeft, TaikoAction.LeftCentre),
|
new KeyBinding(InputKey.MouseLeft, TaikoAction.LeftCentre),
|
||||||
|
@ -919,5 +919,30 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.That(controlPoints[1].Position, Is.Not.EqualTo(Vector2.Zero));
|
Assert.That(controlPoints[1].Position, Is.Not.EqualTo(Vector2.Zero));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNaNControlPoints()
|
||||||
|
{
|
||||||
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("nan-control-points.osu"))
|
||||||
|
using (var stream = new LineBufferedReader(resStream))
|
||||||
|
{
|
||||||
|
var controlPoints = (LegacyControlPointInfo)decoder.Decode(stream).ControlPointInfo;
|
||||||
|
|
||||||
|
Assert.That(controlPoints.TimingPoints.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(controlPoints.DifficultyPoints.Count, Is.EqualTo(2));
|
||||||
|
|
||||||
|
Assert.That(controlPoints.TimingPointAt(1000).BeatLength, Is.EqualTo(500));
|
||||||
|
|
||||||
|
Assert.That(controlPoints.DifficultyPointAt(2000).SliderVelocity, Is.EqualTo(1));
|
||||||
|
Assert.That(controlPoints.DifficultyPointAt(3000).SliderVelocity, Is.EqualTo(1));
|
||||||
|
|
||||||
|
#pragma warning disable 618
|
||||||
|
Assert.That(((LegacyBeatmapDecoder.LegacyDifficultyControlPoint)controlPoints.DifficultyPointAt(2000)).GenerateTicks, Is.False);
|
||||||
|
Assert.That(((LegacyBeatmapDecoder.LegacyDifficultyControlPoint)controlPoints.DifficultyPointAt(3000)).GenerateTicks, Is.True);
|
||||||
|
#pragma warning restore 618
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,12 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
public class ParsingTest
|
public class ParsingTest
|
||||||
{
|
{
|
||||||
[Test]
|
[Test]
|
||||||
public void TestNaNHandling() => allThrow<FormatException>("NaN");
|
public void TestNaNHandling()
|
||||||
|
{
|
||||||
|
allThrow<FormatException>("NaN");
|
||||||
|
Assert.That(Parsing.ParseFloat("NaN", allowNaN: true), Is.NaN);
|
||||||
|
Assert.That(Parsing.ParseDouble("NaN", allowNaN: true), Is.NaN);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBadStringHandling() => allThrow<FormatException>("Random string 123");
|
public void TestBadStringHandling() => allThrow<FormatException>("Random string 123");
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Osu.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Osu.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Database
|
namespace osu.Game.Tests.Database
|
||||||
{
|
{
|
||||||
@ -51,5 +59,105 @@ namespace osu.Game.Tests.Database
|
|||||||
Assert.IsFalse(rulesets.GetRuleset("mania")?.IsManaged);
|
Assert.IsFalse(rulesets.GetRuleset("mania")?.IsManaged);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRulesetThrowingOnMethods()
|
||||||
|
{
|
||||||
|
RunTestWithRealm((realm, storage) =>
|
||||||
|
{
|
||||||
|
LoadTestRuleset.Version = Ruleset.CURRENT_RULESET_API_VERSION;
|
||||||
|
LoadTestRuleset.HasImplementations = false;
|
||||||
|
|
||||||
|
var ruleset = new LoadTestRuleset();
|
||||||
|
string rulesetShortName = ruleset.RulesetInfo.ShortName;
|
||||||
|
|
||||||
|
realm.Write(r => r.Add(new RulesetInfo(rulesetShortName, ruleset.RulesetInfo.Name, ruleset.RulesetInfo.InstantiationInfo, ruleset.RulesetInfo.OnlineID)
|
||||||
|
{
|
||||||
|
Available = true,
|
||||||
|
}));
|
||||||
|
|
||||||
|
Assert.That(realm.Run(r => r.Find<RulesetInfo>(rulesetShortName).Available), Is.True);
|
||||||
|
|
||||||
|
// Availability is updated on construction of a RealmRulesetStore
|
||||||
|
var _ = new RealmRulesetStore(realm, storage);
|
||||||
|
|
||||||
|
Assert.That(realm.Run(r => r.Find<RulesetInfo>(rulesetShortName).Available), Is.False);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOutdatedRulesetNotAvailable()
|
||||||
|
{
|
||||||
|
RunTestWithRealm((realm, storage) =>
|
||||||
|
{
|
||||||
|
LoadTestRuleset.Version = "2021.101.0";
|
||||||
|
LoadTestRuleset.HasImplementations = true;
|
||||||
|
|
||||||
|
var ruleset = new LoadTestRuleset();
|
||||||
|
string rulesetShortName = ruleset.RulesetInfo.ShortName;
|
||||||
|
|
||||||
|
realm.Write(r => r.Add(new RulesetInfo(rulesetShortName, ruleset.RulesetInfo.Name, ruleset.RulesetInfo.InstantiationInfo, ruleset.RulesetInfo.OnlineID)
|
||||||
|
{
|
||||||
|
Available = true,
|
||||||
|
}));
|
||||||
|
|
||||||
|
Assert.That(realm.Run(r => r.Find<RulesetInfo>(rulesetShortName).Available), Is.True);
|
||||||
|
|
||||||
|
// Availability is updated on construction of a RealmRulesetStore
|
||||||
|
var _ = new RealmRulesetStore(realm, storage);
|
||||||
|
|
||||||
|
Assert.That(realm.Run(r => r.Find<RulesetInfo>(rulesetShortName).Available), Is.False);
|
||||||
|
|
||||||
|
// Simulate the ruleset getting updated
|
||||||
|
LoadTestRuleset.Version = Ruleset.CURRENT_RULESET_API_VERSION;
|
||||||
|
var __ = new RealmRulesetStore(realm, storage);
|
||||||
|
|
||||||
|
Assert.That(realm.Run(r => r.Find<RulesetInfo>(rulesetShortName).Available), Is.True);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private class LoadTestRuleset : Ruleset
|
||||||
|
{
|
||||||
|
public override string RulesetAPIVersionSupported => Version;
|
||||||
|
|
||||||
|
public static bool HasImplementations = true;
|
||||||
|
|
||||||
|
public static string Version { get; set; } = CURRENT_RULESET_API_VERSION;
|
||||||
|
|
||||||
|
public override IEnumerable<Mod> GetModsFor(ModType type)
|
||||||
|
{
|
||||||
|
if (!HasImplementations)
|
||||||
|
throw new NotImplementedException();
|
||||||
|
|
||||||
|
return Array.Empty<Mod>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod>? mods = null)
|
||||||
|
{
|
||||||
|
if (!HasImplementations)
|
||||||
|
throw new NotImplementedException();
|
||||||
|
|
||||||
|
return new DrawableOsuRuleset(new OsuRuleset(), beatmap, mods);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap)
|
||||||
|
{
|
||||||
|
if (!HasImplementations)
|
||||||
|
throw new NotImplementedException();
|
||||||
|
|
||||||
|
return new OsuBeatmapConverter(beatmap, new OsuRuleset());
|
||||||
|
}
|
||||||
|
|
||||||
|
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap)
|
||||||
|
{
|
||||||
|
if (!HasImplementations)
|
||||||
|
throw new NotImplementedException();
|
||||||
|
|
||||||
|
return new OsuDifficultyCalculator(new OsuRuleset().RulesetInfo, beatmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string Description => "outdated ruleset";
|
||||||
|
public override string ShortName => "ruleset-outdated";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -23,13 +21,13 @@ namespace osu.Game.Tests.Editing
|
|||||||
[HeadlessTest]
|
[HeadlessTest]
|
||||||
public class TestSceneHitObjectComposerDistanceSnapping : EditorClockTestScene
|
public class TestSceneHitObjectComposerDistanceSnapping : EditorClockTestScene
|
||||||
{
|
{
|
||||||
private TestHitObjectComposer composer;
|
private TestHitObjectComposer composer = null!;
|
||||||
|
|
||||||
[Cached(typeof(EditorBeatmap))]
|
[Cached(typeof(EditorBeatmap))]
|
||||||
[Cached(typeof(IBeatSnapProvider))]
|
[Cached(typeof(IBeatSnapProvider))]
|
||||||
private readonly EditorBeatmap editorBeatmap;
|
private readonly EditorBeatmap editorBeatmap;
|
||||||
|
|
||||||
protected override Container<Drawable> Content { get; }
|
protected override Container<Drawable> Content { get; } = new Container { RelativeSizeAxes = Axes.Both };
|
||||||
|
|
||||||
public TestSceneHitObjectComposerDistanceSnapping()
|
public TestSceneHitObjectComposerDistanceSnapping()
|
||||||
{
|
{
|
||||||
@ -40,15 +38,9 @@ namespace osu.Game.Tests.Editing
|
|||||||
{
|
{
|
||||||
editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
editorBeatmap = new EditorBeatmap(new OsuBeatmap
|
||||||
{
|
{
|
||||||
BeatmapInfo =
|
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||||
{
|
|
||||||
Ruleset = new OsuRuleset().RulesetInfo,
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
Content = new Container
|
Content
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -205,7 +197,7 @@ namespace osu.Game.Tests.Editing
|
|||||||
assertSnappedDistance(400, 400);
|
assertSnappedDistance(400, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSnapDistance(float expectedDistance, HitObject hitObject = null)
|
private void assertSnapDistance(float expectedDistance, HitObject? hitObject = null)
|
||||||
=> AddAssert($"distance is {expectedDistance}", () => composer.GetBeatSnapDistanceAt(hitObject ?? new HitObject()), () => Is.EqualTo(expectedDistance));
|
=> AddAssert($"distance is {expectedDistance}", () => composer.GetBeatSnapDistanceAt(hitObject ?? new HitObject()), () => Is.EqualTo(expectedDistance));
|
||||||
|
|
||||||
private void assertDurationToDistance(double duration, float expectedDistance)
|
private void assertDurationToDistance(double duration, float expectedDistance)
|
||||||
|
@ -124,14 +124,19 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
|
|
||||||
Assert.That(score.Rank, Is.EqualTo(ScoreRank.F));
|
Assert.That(score.Rank, Is.EqualTo(ScoreRank.F));
|
||||||
Assert.That(score.Passed, Is.False);
|
Assert.That(score.Passed, Is.False);
|
||||||
Assert.That(score.Statistics.Count(kvp => kvp.Value > 0), Is.EqualTo(7));
|
Assert.That(score.Statistics.Sum(kvp => kvp.Value), Is.EqualTo(4));
|
||||||
|
Assert.That(score.MaximumStatistics.Sum(kvp => kvp.Value), Is.EqualTo(8));
|
||||||
|
|
||||||
Assert.That(score.Statistics[HitResult.Ok], Is.EqualTo(1));
|
Assert.That(score.Statistics[HitResult.Ok], Is.EqualTo(1));
|
||||||
Assert.That(score.Statistics[HitResult.Miss], Is.EqualTo(1));
|
|
||||||
Assert.That(score.Statistics[HitResult.LargeTickHit], Is.EqualTo(1));
|
Assert.That(score.Statistics[HitResult.LargeTickHit], Is.EqualTo(1));
|
||||||
Assert.That(score.Statistics[HitResult.LargeTickMiss], Is.EqualTo(1));
|
Assert.That(score.Statistics[HitResult.SmallTickMiss], Is.EqualTo(1));
|
||||||
Assert.That(score.Statistics[HitResult.SmallTickMiss], Is.EqualTo(2));
|
|
||||||
Assert.That(score.Statistics[HitResult.SmallBonus], Is.EqualTo(1));
|
Assert.That(score.Statistics[HitResult.SmallBonus], Is.EqualTo(1));
|
||||||
Assert.That(score.Statistics[HitResult.IgnoreMiss], Is.EqualTo(1));
|
|
||||||
|
Assert.That(score.MaximumStatistics[HitResult.Perfect], Is.EqualTo(2));
|
||||||
|
Assert.That(score.MaximumStatistics[HitResult.LargeTickHit], Is.EqualTo(2));
|
||||||
|
Assert.That(score.MaximumStatistics[HitResult.SmallTickHit], Is.EqualTo(2));
|
||||||
|
Assert.That(score.MaximumStatistics[HitResult.SmallBonus], Is.EqualTo(1));
|
||||||
|
Assert.That(score.MaximumStatistics[HitResult.LargeBonus], Is.EqualTo(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestJudgement : Judgement
|
private class TestJudgement : Judgement
|
||||||
|
@ -194,8 +194,16 @@ namespace osu.Game.Tests.Resources
|
|||||||
[HitResult.LargeTickHit] = 100,
|
[HitResult.LargeTickHit] = 100,
|
||||||
[HitResult.LargeTickMiss] = 50,
|
[HitResult.LargeTickMiss] = 50,
|
||||||
[HitResult.SmallBonus] = 10,
|
[HitResult.SmallBonus] = 10,
|
||||||
[HitResult.SmallBonus] = 50
|
[HitResult.LargeBonus] = 50
|
||||||
},
|
},
|
||||||
|
MaximumStatistics = new Dictionary<HitResult, int>
|
||||||
|
{
|
||||||
|
[HitResult.Perfect] = 971,
|
||||||
|
[HitResult.SmallTickHit] = 75,
|
||||||
|
[HitResult.LargeTickHit] = 150,
|
||||||
|
[HitResult.SmallBonus] = 10,
|
||||||
|
[HitResult.LargeBonus] = 50,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private class TestModHardRock : ModHardRock
|
private class TestModHardRock : ModHardRock
|
||||||
|
15
osu.Game.Tests/Resources/nan-control-points.osu
Normal file
15
osu.Game.Tests/Resources/nan-control-points.osu
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
osu file format v14
|
||||||
|
|
||||||
|
[TimingPoints]
|
||||||
|
|
||||||
|
// NaN bpm (should be rejected)
|
||||||
|
0,NaN,4,2,0,100,1,0
|
||||||
|
|
||||||
|
// 120 bpm
|
||||||
|
1000,500,4,2,0,100,1,0
|
||||||
|
|
||||||
|
// NaN slider velocity
|
||||||
|
2000,NaN,4,3,0,100,0,1
|
||||||
|
|
||||||
|
// 1.0x slider velocity
|
||||||
|
3000,-100,4,3,0,100,0,1
|
@ -9,6 +9,7 @@ using osu.Framework.Extensions.ObjectExtensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
@ -34,9 +35,11 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
var beatmap = new OsuBeatmap
|
var beatmap = new OsuBeatmap
|
||||||
{
|
{
|
||||||
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo }
|
BeatmapInfo = { Ruleset = new OsuRuleset().RulesetInfo },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
beatmap.ControlPointInfo.Add(0, new TimingControlPoint());
|
||||||
|
|
||||||
editorBeatmap = new EditorBeatmap(beatmap, new LegacyBeatmapSkin(beatmap.BeatmapInfo, null));
|
editorBeatmap = new EditorBeatmap(beatmap, new LegacyBeatmapSkin(beatmap.BeatmapInfo, null));
|
||||||
|
|
||||||
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
|
Beatmap.Value = CreateWorkingBeatmap(editorBeatmap.PlayableBeatmap);
|
||||||
@ -50,7 +53,11 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
(typeof(IBeatSnapProvider), editorBeatmap),
|
(typeof(IBeatSnapProvider), editorBeatmap),
|
||||||
(typeof(OverlayColourProvider), new OverlayColourProvider(OverlayColourScheme.Green)),
|
(typeof(OverlayColourProvider), new OverlayColourProvider(OverlayColourScheme.Green)),
|
||||||
},
|
},
|
||||||
Child = new ComposeScreen { State = { Value = Visibility.Visible } },
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
editorBeatmap,
|
||||||
|
new ComposeScreen { State = { Value = Visibility.Visible } },
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -55,51 +55,51 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestStopAtTrackEnd()
|
public void TestStopAtTrackEnd()
|
||||||
{
|
{
|
||||||
AddStep("reset clock", () => Clock.Seek(0));
|
AddStep("reset clock", () => EditorClock.Seek(0));
|
||||||
|
|
||||||
AddStep("start clock", () => Clock.Start());
|
AddStep("start clock", () => EditorClock.Start());
|
||||||
AddAssert("clock running", () => Clock.IsRunning);
|
AddAssert("clock running", () => EditorClock.IsRunning);
|
||||||
|
|
||||||
AddStep("seek near end", () => Clock.Seek(Clock.TrackLength - 250));
|
AddStep("seek near end", () => EditorClock.Seek(EditorClock.TrackLength - 250));
|
||||||
AddUntilStep("clock stops", () => !Clock.IsRunning);
|
AddUntilStep("clock stops", () => !EditorClock.IsRunning);
|
||||||
|
|
||||||
AddUntilStep("clock stopped at end", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
AddUntilStep("clock stopped at end", () => EditorClock.CurrentTime - EditorClock.TotalAppliedOffset, () => Is.EqualTo(EditorClock.TrackLength));
|
||||||
|
|
||||||
AddStep("start clock again", () => Clock.Start());
|
AddStep("start clock again", () => EditorClock.Start());
|
||||||
AddAssert("clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
|
AddAssert("clock looped to start", () => EditorClock.IsRunning && EditorClock.CurrentTime < 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestWrapWhenStoppedAtTrackEnd()
|
public void TestWrapWhenStoppedAtTrackEnd()
|
||||||
{
|
{
|
||||||
AddStep("reset clock", () => Clock.Seek(0));
|
AddStep("reset clock", () => EditorClock.Seek(0));
|
||||||
|
|
||||||
AddStep("stop clock", () => Clock.Stop());
|
AddStep("stop clock", () => EditorClock.Stop());
|
||||||
AddAssert("clock stopped", () => !Clock.IsRunning);
|
AddAssert("clock stopped", () => !EditorClock.IsRunning);
|
||||||
|
|
||||||
AddStep("seek exactly to end", () => Clock.Seek(Clock.TrackLength));
|
AddStep("seek exactly to end", () => EditorClock.Seek(EditorClock.TrackLength));
|
||||||
AddAssert("clock stopped at end", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
AddAssert("clock stopped at end", () => EditorClock.CurrentTime, () => Is.EqualTo(EditorClock.TrackLength));
|
||||||
|
|
||||||
AddStep("start clock again", () => Clock.Start());
|
AddStep("start clock again", () => EditorClock.Start());
|
||||||
AddAssert("clock looped to start", () => Clock.IsRunning && Clock.CurrentTime < 500);
|
AddAssert("clock looped to start", () => EditorClock.IsRunning && EditorClock.CurrentTime < 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestClampWhenSeekOutsideBeatmapBounds()
|
public void TestClampWhenSeekOutsideBeatmapBounds()
|
||||||
{
|
{
|
||||||
AddStep("stop clock", () => Clock.Stop());
|
AddStep("stop clock", () => EditorClock.Stop());
|
||||||
|
|
||||||
AddStep("seek before start time", () => Clock.Seek(-1000));
|
AddStep("seek before start time", () => EditorClock.Seek(-1000));
|
||||||
AddAssert("time is clamped to 0", () => Clock.CurrentTime, () => Is.EqualTo(0));
|
AddAssert("time is clamped to 0", () => EditorClock.CurrentTime, () => Is.EqualTo(0));
|
||||||
|
|
||||||
AddStep("seek beyond track length", () => Clock.Seek(Clock.TrackLength + 1000));
|
AddStep("seek beyond track length", () => EditorClock.Seek(EditorClock.TrackLength + 1000));
|
||||||
AddAssert("time is clamped to track length", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
AddAssert("time is clamped to track length", () => EditorClock.CurrentTime, () => Is.EqualTo(EditorClock.TrackLength));
|
||||||
|
|
||||||
AddStep("seek smoothly before start time", () => Clock.SeekSmoothlyTo(-1000));
|
AddStep("seek smoothly before start time", () => EditorClock.SeekSmoothlyTo(-1000));
|
||||||
AddUntilStep("time is clamped to 0", () => Clock.CurrentTime, () => Is.EqualTo(0));
|
AddUntilStep("time is clamped to 0", () => EditorClock.CurrentTime, () => Is.EqualTo(0));
|
||||||
|
|
||||||
AddStep("seek smoothly beyond track length", () => Clock.SeekSmoothlyTo(Clock.TrackLength + 1000));
|
AddStep("seek smoothly beyond track length", () => EditorClock.SeekSmoothlyTo(EditorClock.TrackLength + 1000));
|
||||||
AddUntilStep("time is clamped to track length", () => Clock.CurrentTime, () => Is.EqualTo(Clock.TrackLength));
|
AddUntilStep("time is clamped to track length", () => EditorClock.CurrentTime, () => Is.EqualTo(EditorClock.TrackLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -28,6 +28,11 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
Child = new TimingPointVisualiser(Beatmap.Value.Beatmap, 5000) { Clock = EditorClock };
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Beatmap CreateEditorClockBeatmap()
|
||||||
|
{
|
||||||
var testBeatmap = new Beatmap
|
var testBeatmap = new Beatmap
|
||||||
{
|
{
|
||||||
ControlPointInfo = new ControlPointInfo(),
|
ControlPointInfo = new ControlPointInfo(),
|
||||||
@ -45,9 +50,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
testBeatmap.ControlPointInfo.Add(450, new TimingControlPoint { BeatLength = 100 });
|
testBeatmap.ControlPointInfo.Add(450, new TimingControlPoint { BeatLength = 100 });
|
||||||
testBeatmap.ControlPointInfo.Add(500, new TimingControlPoint { BeatLength = 307.69230769230802 });
|
testBeatmap.ControlPointInfo.Add(500, new TimingControlPoint { BeatLength = 307.69230769230802 });
|
||||||
|
|
||||||
Beatmap.Value = CreateWorkingBeatmap(testBeatmap);
|
return testBeatmap;
|
||||||
|
|
||||||
Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -59,17 +62,17 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
reset();
|
reset();
|
||||||
|
|
||||||
// Forwards
|
// Forwards
|
||||||
AddStep("Seek(0)", () => Clock.Seek(0));
|
AddStep("Seek(0)", () => EditorClock.Seek(0));
|
||||||
checkTime(0);
|
checkTime(0);
|
||||||
AddStep("Seek(33)", () => Clock.Seek(33));
|
AddStep("Seek(33)", () => EditorClock.Seek(33));
|
||||||
checkTime(33);
|
checkTime(33);
|
||||||
AddStep("Seek(89)", () => Clock.Seek(89));
|
AddStep("Seek(89)", () => EditorClock.Seek(89));
|
||||||
checkTime(89);
|
checkTime(89);
|
||||||
|
|
||||||
// Backwards
|
// Backwards
|
||||||
AddStep("Seek(25)", () => Clock.Seek(25));
|
AddStep("Seek(25)", () => EditorClock.Seek(25));
|
||||||
checkTime(25);
|
checkTime(25);
|
||||||
AddStep("Seek(0)", () => Clock.Seek(0));
|
AddStep("Seek(0)", () => EditorClock.Seek(0));
|
||||||
checkTime(0);
|
checkTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,19 +85,19 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
AddStep("Seek(0), Snap", () => Clock.SeekSnapped(0));
|
AddStep("Seek(0), Snap", () => EditorClock.SeekSnapped(0));
|
||||||
checkTime(0);
|
checkTime(0);
|
||||||
AddStep("Seek(50), Snap", () => Clock.SeekSnapped(50));
|
AddStep("Seek(50), Snap", () => EditorClock.SeekSnapped(50));
|
||||||
checkTime(50);
|
checkTime(50);
|
||||||
AddStep("Seek(100), Snap", () => Clock.SeekSnapped(100));
|
AddStep("Seek(100), Snap", () => EditorClock.SeekSnapped(100));
|
||||||
checkTime(100);
|
checkTime(100);
|
||||||
AddStep("Seek(175), Snap", () => Clock.SeekSnapped(175));
|
AddStep("Seek(175), Snap", () => EditorClock.SeekSnapped(175));
|
||||||
checkTime(175);
|
checkTime(175);
|
||||||
AddStep("Seek(350), Snap", () => Clock.SeekSnapped(350));
|
AddStep("Seek(350), Snap", () => EditorClock.SeekSnapped(350));
|
||||||
checkTime(350);
|
checkTime(350);
|
||||||
AddStep("Seek(400), Snap", () => Clock.SeekSnapped(400));
|
AddStep("Seek(400), Snap", () => EditorClock.SeekSnapped(400));
|
||||||
checkTime(400);
|
checkTime(400);
|
||||||
AddStep("Seek(450), Snap", () => Clock.SeekSnapped(450));
|
AddStep("Seek(450), Snap", () => EditorClock.SeekSnapped(450));
|
||||||
checkTime(450);
|
checkTime(450);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,17 +110,17 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
AddStep("Seek(24), Snap", () => Clock.SeekSnapped(24));
|
AddStep("Seek(24), Snap", () => EditorClock.SeekSnapped(24));
|
||||||
checkTime(0);
|
checkTime(0);
|
||||||
AddStep("Seek(26), Snap", () => Clock.SeekSnapped(26));
|
AddStep("Seek(26), Snap", () => EditorClock.SeekSnapped(26));
|
||||||
checkTime(50);
|
checkTime(50);
|
||||||
AddStep("Seek(150), Snap", () => Clock.SeekSnapped(150));
|
AddStep("Seek(150), Snap", () => EditorClock.SeekSnapped(150));
|
||||||
checkTime(100);
|
checkTime(100);
|
||||||
AddStep("Seek(170), Snap", () => Clock.SeekSnapped(170));
|
AddStep("Seek(170), Snap", () => EditorClock.SeekSnapped(170));
|
||||||
checkTime(175);
|
checkTime(175);
|
||||||
AddStep("Seek(274), Snap", () => Clock.SeekSnapped(274));
|
AddStep("Seek(274), Snap", () => EditorClock.SeekSnapped(274));
|
||||||
checkTime(175);
|
checkTime(175);
|
||||||
AddStep("Seek(276), Snap", () => Clock.SeekSnapped(276));
|
AddStep("Seek(276), Snap", () => EditorClock.SeekSnapped(276));
|
||||||
checkTime(350);
|
checkTime(350);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,15 +132,15 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
AddStep("SeekForward", () => Clock.SeekForward());
|
AddStep("SeekForward", () => EditorClock.SeekForward());
|
||||||
checkTime(50);
|
checkTime(50);
|
||||||
AddStep("SeekForward", () => Clock.SeekForward());
|
AddStep("SeekForward", () => EditorClock.SeekForward());
|
||||||
checkTime(100);
|
checkTime(100);
|
||||||
AddStep("SeekForward", () => Clock.SeekForward());
|
AddStep("SeekForward", () => EditorClock.SeekForward());
|
||||||
checkTime(200);
|
checkTime(200);
|
||||||
AddStep("SeekForward", () => Clock.SeekForward());
|
AddStep("SeekForward", () => EditorClock.SeekForward());
|
||||||
checkTime(400);
|
checkTime(400);
|
||||||
AddStep("SeekForward", () => Clock.SeekForward());
|
AddStep("SeekForward", () => EditorClock.SeekForward());
|
||||||
checkTime(450);
|
checkTime(450);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,17 +152,17 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(50);
|
checkTime(50);
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(100);
|
checkTime(100);
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(175);
|
checkTime(175);
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(350);
|
checkTime(350);
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(400);
|
checkTime(400);
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(450);
|
checkTime(450);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,30 +175,30 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
AddStep("Seek(49)", () => Clock.Seek(49));
|
AddStep("Seek(49)", () => EditorClock.Seek(49));
|
||||||
checkTime(49);
|
checkTime(49);
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(50);
|
checkTime(50);
|
||||||
AddStep("Seek(49.999)", () => Clock.Seek(49.999));
|
AddStep("Seek(49.999)", () => EditorClock.Seek(49.999));
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(100);
|
checkTime(100);
|
||||||
AddStep("Seek(99)", () => Clock.Seek(99));
|
AddStep("Seek(99)", () => EditorClock.Seek(99));
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(100);
|
checkTime(100);
|
||||||
AddStep("Seek(99.999)", () => Clock.Seek(99.999));
|
AddStep("Seek(99.999)", () => EditorClock.Seek(99.999));
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(150);
|
checkTime(150);
|
||||||
AddStep("Seek(174)", () => Clock.Seek(174));
|
AddStep("Seek(174)", () => EditorClock.Seek(174));
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(175);
|
checkTime(175);
|
||||||
AddStep("Seek(349)", () => Clock.Seek(349));
|
AddStep("Seek(349)", () => EditorClock.Seek(349));
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(350);
|
checkTime(350);
|
||||||
AddStep("Seek(399)", () => Clock.Seek(399));
|
AddStep("Seek(399)", () => EditorClock.Seek(399));
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(400);
|
checkTime(400);
|
||||||
AddStep("Seek(449)", () => Clock.Seek(449));
|
AddStep("Seek(449)", () => EditorClock.Seek(449));
|
||||||
AddStep("SeekForward, Snap", () => Clock.SeekForward(true));
|
AddStep("SeekForward, Snap", () => EditorClock.SeekForward(true));
|
||||||
checkTime(450);
|
checkTime(450);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,17 +210,17 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
AddStep("Seek(450)", () => Clock.Seek(450));
|
AddStep("Seek(450)", () => EditorClock.Seek(450));
|
||||||
checkTime(450);
|
checkTime(450);
|
||||||
AddStep("SeekBackward", () => Clock.SeekBackward());
|
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
||||||
checkTime(400);
|
checkTime(400);
|
||||||
AddStep("SeekBackward", () => Clock.SeekBackward());
|
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
||||||
checkTime(350);
|
checkTime(350);
|
||||||
AddStep("SeekBackward", () => Clock.SeekBackward());
|
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
||||||
checkTime(150);
|
checkTime(150);
|
||||||
AddStep("SeekBackward", () => Clock.SeekBackward());
|
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
||||||
checkTime(50);
|
checkTime(50);
|
||||||
AddStep("SeekBackward", () => Clock.SeekBackward());
|
AddStep("SeekBackward", () => EditorClock.SeekBackward());
|
||||||
checkTime(0);
|
checkTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,19 +232,19 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
AddStep("Seek(450)", () => Clock.Seek(450));
|
AddStep("Seek(450)", () => EditorClock.Seek(450));
|
||||||
checkTime(450);
|
checkTime(450);
|
||||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||||
checkTime(400);
|
checkTime(400);
|
||||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||||
checkTime(350);
|
checkTime(350);
|
||||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||||
checkTime(175);
|
checkTime(175);
|
||||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||||
checkTime(100);
|
checkTime(100);
|
||||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||||
checkTime(50);
|
checkTime(50);
|
||||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||||
checkTime(0);
|
checkTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,18 +257,18 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
AddStep("Seek(451)", () => Clock.Seek(451));
|
AddStep("Seek(451)", () => EditorClock.Seek(451));
|
||||||
checkTime(451);
|
checkTime(451);
|
||||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||||
checkTime(450);
|
checkTime(450);
|
||||||
AddStep("Seek(450.999)", () => Clock.Seek(450.999));
|
AddStep("Seek(450.999)", () => EditorClock.Seek(450.999));
|
||||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||||
checkTime(450);
|
checkTime(450);
|
||||||
AddStep("Seek(401)", () => Clock.Seek(401));
|
AddStep("Seek(401)", () => EditorClock.Seek(401));
|
||||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||||
checkTime(400);
|
checkTime(400);
|
||||||
AddStep("Seek(401.999)", () => Clock.Seek(401.999));
|
AddStep("Seek(401.999)", () => EditorClock.Seek(401.999));
|
||||||
AddStep("SeekBackward, Snap", () => Clock.SeekBackward(true));
|
AddStep("SeekBackward, Snap", () => EditorClock.SeekBackward(true));
|
||||||
checkTime(400);
|
checkTime(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,37 +282,37 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
|
|
||||||
double lastTime = 0;
|
double lastTime = 0;
|
||||||
|
|
||||||
AddStep("Seek(0)", () => Clock.Seek(0));
|
AddStep("Seek(0)", () => EditorClock.Seek(0));
|
||||||
checkTime(0);
|
checkTime(0);
|
||||||
|
|
||||||
for (int i = 0; i < 9; i++)
|
for (int i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
AddStep("SeekForward, Snap", () =>
|
AddStep("SeekForward, Snap", () =>
|
||||||
{
|
{
|
||||||
lastTime = Clock.CurrentTime;
|
lastTime = EditorClock.CurrentTime;
|
||||||
Clock.SeekForward(true);
|
EditorClock.SeekForward(true);
|
||||||
});
|
});
|
||||||
AddAssert("Time > lastTime", () => Clock.CurrentTime > lastTime);
|
AddAssert("Time > lastTime", () => EditorClock.CurrentTime > lastTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 9; i++)
|
for (int i = 0; i < 9; i++)
|
||||||
{
|
{
|
||||||
AddStep("SeekBackward, Snap", () =>
|
AddStep("SeekBackward, Snap", () =>
|
||||||
{
|
{
|
||||||
lastTime = Clock.CurrentTime;
|
lastTime = EditorClock.CurrentTime;
|
||||||
Clock.SeekBackward(true);
|
EditorClock.SeekBackward(true);
|
||||||
});
|
});
|
||||||
AddAssert("Time < lastTime", () => Clock.CurrentTime < lastTime);
|
AddAssert("Time < lastTime", () => EditorClock.CurrentTime < lastTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkTime(0);
|
checkTime(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTime(double expectedTime) => AddAssert($"Current time is {expectedTime}", () => Clock.CurrentTime, () => Is.EqualTo(expectedTime));
|
private void checkTime(double expectedTime) => AddUntilStep($"Current time is {expectedTime}", () => EditorClock.CurrentTime, () => Is.EqualTo(expectedTime));
|
||||||
|
|
||||||
private void reset()
|
private void reset()
|
||||||
{
|
{
|
||||||
AddStep("Reset", () => Clock.Seek(0));
|
AddStep("Reset", () => EditorClock.Seek(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TimingPointVisualiser : CompositeDrawable
|
private class TimingPointVisualiser : CompositeDrawable
|
||||||
|
@ -113,7 +113,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
.TriggerClick();
|
.TriggerClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for track playing", () => Clock.IsRunning);
|
AddUntilStep("wait for track playing", () => EditorClock.IsRunning);
|
||||||
|
|
||||||
AddStep("click reset button", () =>
|
AddStep("click reset button", () =>
|
||||||
{
|
{
|
||||||
@ -122,7 +122,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
.TriggerClick();
|
.TriggerClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("wait for track stopped", () => !Clock.IsRunning);
|
AddUntilStep("wait for track stopped", () => !EditorClock.IsRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -17,7 +17,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
Clock.Seek(10000);
|
EditorClock.Seek(10000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,6 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
double initialVisibleRange = 0;
|
double initialVisibleRange = 0;
|
||||||
|
|
||||||
AddUntilStep("wait for load", () => MusicController.TrackLoaded);
|
|
||||||
|
|
||||||
AddStep("reset zoom", () => TimelineArea.Timeline.Zoom = 100);
|
AddStep("reset zoom", () => TimelineArea.Timeline.Zoom = 100);
|
||||||
AddStep("get initial range", () => initialVisibleRange = TimelineArea.Timeline.VisibleRange);
|
AddStep("get initial range", () => initialVisibleRange = TimelineArea.Timeline.VisibleRange);
|
||||||
|
|
||||||
@ -36,8 +34,6 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
{
|
{
|
||||||
double initialVisibleRange = 0;
|
double initialVisibleRange = 0;
|
||||||
|
|
||||||
AddUntilStep("wait for load", () => MusicController.TrackLoaded);
|
|
||||||
|
|
||||||
AddStep("reset timeline size", () => TimelineArea.Timeline.Width = 1);
|
AddStep("reset timeline size", () => TimelineArea.Timeline.Width = 1);
|
||||||
AddStep("get initial range", () => initialVisibleRange = TimelineArea.Timeline.VisibleRange);
|
AddStep("get initial range", () => initialVisibleRange = TimelineArea.Timeline.VisibleRange);
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
[SetUpSteps]
|
[SetUpSteps]
|
||||||
public void SetUpSteps()
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
AddStep("Stop clock", () => Clock.Stop());
|
AddStep("Stop clock", () => EditorClock.Stop());
|
||||||
|
|
||||||
AddUntilStep("wait for rows to load", () => Child.ChildrenOfType<EffectRowAttribute>().Any());
|
AddUntilStep("wait for rows to load", () => Child.ChildrenOfType<EffectRowAttribute>().Any());
|
||||||
}
|
}
|
||||||
@ -68,10 +68,10 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 54670);
|
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 54670);
|
||||||
AddUntilStep("Ensure seeked to correct time", () => Clock.CurrentTimeAccurate == 54670);
|
AddUntilStep("Ensure seeked to correct time", () => EditorClock.CurrentTimeAccurate == 54670);
|
||||||
|
|
||||||
AddStep("Seek to just before next point", () => Clock.Seek(69000));
|
AddStep("Seek to just before next point", () => EditorClock.Seek(69000));
|
||||||
AddStep("Start clock", () => Clock.Start());
|
AddStep("Start clock", () => EditorClock.Start());
|
||||||
|
|
||||||
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 69670);
|
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 69670);
|
||||||
}
|
}
|
||||||
@ -86,9 +86,9 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 54670);
|
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 54670);
|
||||||
AddUntilStep("Ensure seeked to correct time", () => Clock.CurrentTimeAccurate == 54670);
|
AddUntilStep("Ensure seeked to correct time", () => EditorClock.CurrentTimeAccurate == 54670);
|
||||||
|
|
||||||
AddStep("Seek to later", () => Clock.Seek(80000));
|
AddStep("Seek to later", () => EditorClock.Seek(80000));
|
||||||
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 69670);
|
AddUntilStep("Selection changed", () => timingScreen.SelectedGroup.Value.Time == 69670);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,12 +9,14 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||||
|
using osu.Game.Storyboards;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -28,10 +30,14 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
|
|
||||||
protected EditorBeatmap EditorBeatmap { get; private set; }
|
protected EditorBeatmap EditorBeatmap { get; private set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[Resolved]
|
||||||
private void load(AudioManager audio)
|
private AudioManager audio { get; set; }
|
||||||
|
|
||||||
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) => new WaveformTestBeatmap(audio);
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
Beatmap.Value = new WaveformTestBeatmap(audio);
|
base.LoadComplete();
|
||||||
|
|
||||||
var playable = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
|
var playable = Beatmap.Value.GetPlayableBeatmap(Beatmap.Value.BeatmapInfo.Ruleset);
|
||||||
EditorBeatmap = new EditorBeatmap(playable);
|
EditorBeatmap = new EditorBeatmap(playable);
|
||||||
@ -68,11 +74,11 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
AddUntilStep("wait for track loaded", () => MusicController.TrackLoaded);
|
||||||
|
AddStep("seek forward", () => EditorClock.Seek(2500));
|
||||||
Clock.Seek(2500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Drawable CreateTestComponent();
|
public abstract Drawable CreateTestComponent();
|
||||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
Player.OnUpdate += _ =>
|
Player.OnUpdate += _ =>
|
||||||
{
|
{
|
||||||
double currentTime = Player.GameplayClockContainer.CurrentTime;
|
double currentTime = Player.GameplayClockContainer.CurrentTime;
|
||||||
alwaysGoingForward &= currentTime >= lastTime;
|
alwaysGoingForward &= currentTime >= lastTime - 500;
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -77,7 +77,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
resumeAndConfirm();
|
resumeAndConfirm();
|
||||||
|
|
||||||
AddAssert("time didn't go backwards", () => alwaysGoingForward);
|
AddAssert("time didn't go too far backwards", () => alwaysGoingForward);
|
||||||
|
|
||||||
AddStep("reset offset", () => LocalConfig.SetValue(OsuSetting.AudioOffset, 0.0));
|
AddStep("reset offset", () => LocalConfig.SetValue(OsuSetting.AudioOffset, 0.0));
|
||||||
}
|
}
|
||||||
@ -90,6 +90,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("player not playing", () => !Player.LocalUserPlaying.Value);
|
AddAssert("player not playing", () => !Player.LocalUserPlaying.Value);
|
||||||
|
|
||||||
resumeAndConfirm();
|
resumeAndConfirm();
|
||||||
|
|
||||||
|
AddAssert("Resumed without seeking forward", () => Player.LastResumeTime, () => Is.LessThanOrEqualTo(Player.LastPauseTime));
|
||||||
|
|
||||||
AddUntilStep("player playing", () => Player.LocalUserPlaying.Value);
|
AddUntilStep("player playing", () => Player.LocalUserPlaying.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +381,16 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddAssert("pause overlay " + (isShown ? "shown" : "hidden"), () => Player.PauseOverlayVisible == isShown);
|
AddAssert("pause overlay " + (isShown ? "shown" : "hidden"), () => Player.PauseOverlayVisible == isShown);
|
||||||
|
|
||||||
private void confirmClockRunning(bool isRunning) =>
|
private void confirmClockRunning(bool isRunning) =>
|
||||||
AddUntilStep("clock " + (isRunning ? "running" : "stopped"), () => Player.GameplayClockContainer.IsRunning == isRunning);
|
AddUntilStep("clock " + (isRunning ? "running" : "stopped"), () =>
|
||||||
|
{
|
||||||
|
bool completed = Player.GameplayClockContainer.IsRunning == isRunning;
|
||||||
|
|
||||||
|
if (completed)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return completed;
|
||||||
|
});
|
||||||
|
|
||||||
protected override bool AllowFail => true;
|
protected override bool AllowFail => true;
|
||||||
|
|
||||||
@ -386,6 +398,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
protected class PausePlayer : TestPlayer
|
protected class PausePlayer : TestPlayer
|
||||||
{
|
{
|
||||||
|
public double LastPauseTime { get; private set; }
|
||||||
|
public double LastResumeTime { get; private set; }
|
||||||
|
|
||||||
public bool FailOverlayVisible => FailOverlay.State.Value == Visibility.Visible;
|
public bool FailOverlayVisible => FailOverlay.State.Value == Visibility.Visible;
|
||||||
|
|
||||||
public bool PauseOverlayVisible => PauseOverlay.State.Value == Visibility.Visible;
|
public bool PauseOverlayVisible => PauseOverlay.State.Value == Visibility.Visible;
|
||||||
@ -399,6 +414,23 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
base.OnEntering(e);
|
base.OnEntering(e);
|
||||||
GameplayClockContainer.Stop();
|
GameplayClockContainer.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool? isRunning;
|
||||||
|
|
||||||
|
protected override void UpdateAfterChildren()
|
||||||
|
{
|
||||||
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
|
if (GameplayClockContainer.IsRunning != isRunning)
|
||||||
|
{
|
||||||
|
isRunning = GameplayClockContainer.IsRunning;
|
||||||
|
|
||||||
|
if (isRunning.Value)
|
||||||
|
LastResumeTime = GameplayClockContainer.CurrentTime;
|
||||||
|
else
|
||||||
|
LastPauseTime = GameplayClockContainer.CurrentTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,10 @@ using osu.Framework.Audio;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -30,7 +29,6 @@ using osu.Game.Screens.Play;
|
|||||||
using osu.Game.Screens.Play.PlayerSettings;
|
using osu.Game.Screens.Play.PlayerSettings;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
using SkipOverlay = osu.Game.Screens.Play.SkipOverlay;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Gameplay
|
namespace osu.Game.Tests.Visual.Gameplay
|
||||||
{
|
{
|
||||||
@ -83,6 +81,20 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() => player = null);
|
public void Setup() => Schedule(() => player = null);
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public override void SetUpSteps()
|
||||||
|
{
|
||||||
|
base.SetUpSteps();
|
||||||
|
|
||||||
|
AddStep("read all notifications", () =>
|
||||||
|
{
|
||||||
|
notificationOverlay.Show();
|
||||||
|
notificationOverlay.Hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for no notifications", () => notificationOverlay.UnreadCount.Value, () => Is.EqualTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the input manager child to a new test player loader container instance.
|
/// Sets the input manager child to a new test player loader container instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -287,16 +299,9 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
saveVolumes();
|
saveVolumes();
|
||||||
|
|
||||||
AddAssert("check for notification", () => notificationOverlay.UnreadCount.Value == 1);
|
AddAssert("check for notification", () => notificationOverlay.UnreadCount.Value, () => Is.EqualTo(1));
|
||||||
AddStep("click notification", () =>
|
|
||||||
{
|
|
||||||
var scrollContainer = (OsuScrollContainer)notificationOverlay.Children.Last();
|
|
||||||
var flowContainer = scrollContainer.Children.OfType<FillFlowContainer<NotificationSection>>().First();
|
|
||||||
var notification = flowContainer.First();
|
|
||||||
|
|
||||||
InputManager.MoveMouseTo(notification);
|
clickNotificationIfAny();
|
||||||
InputManager.Click(MouseButton.Left);
|
|
||||||
});
|
|
||||||
|
|
||||||
AddAssert("check " + volumeName, assert);
|
AddAssert("check " + volumeName, assert);
|
||||||
|
|
||||||
@ -366,15 +371,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
}));
|
}));
|
||||||
AddUntilStep("wait for player", () => player?.LoadState == LoadState.Ready);
|
AddUntilStep("wait for player", () => player?.LoadState == LoadState.Ready);
|
||||||
AddAssert($"notification {(shouldWarn ? "triggered" : "not triggered")}", () => notificationOverlay.UnreadCount.Value == (shouldWarn ? 1 : 0));
|
AddAssert($"notification {(shouldWarn ? "triggered" : "not triggered")}", () => notificationOverlay.UnreadCount.Value == (shouldWarn ? 1 : 0));
|
||||||
AddStep("click notification", () =>
|
clickNotificationIfAny();
|
||||||
{
|
|
||||||
var scrollContainer = (OsuScrollContainer)notificationOverlay.Children.Last();
|
|
||||||
var flowContainer = scrollContainer.Children.OfType<FillFlowContainer<NotificationSection>>().First();
|
|
||||||
var notification = flowContainer.First();
|
|
||||||
|
|
||||||
InputManager.MoveMouseTo(notification);
|
|
||||||
InputManager.Click(MouseButton.Left);
|
|
||||||
});
|
|
||||||
AddUntilStep("wait for player load", () => player.IsLoaded);
|
AddUntilStep("wait for player load", () => player.IsLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,6 +436,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
AddUntilStep("skip button not visible", () => !checkSkipButtonVisible());
|
AddUntilStep("skip button not visible", () => !checkSkipButtonVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clickNotificationIfAny()
|
||||||
|
{
|
||||||
|
AddStep("click notification", () => notificationOverlay.ChildrenOfType<Notification>().FirstOrDefault()?.TriggerClick());
|
||||||
|
}
|
||||||
|
|
||||||
private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault();
|
private EpilepsyWarning getWarning() => loader.ChildrenOfType<EpilepsyWarning>().SingleOrDefault();
|
||||||
|
|
||||||
private class TestPlayerLoader : PlayerLoader
|
private class TestPlayerLoader : PlayerLoader
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
{
|
{
|
||||||
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
||||||
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, Realm, null, audio, Resources, host, Beatmap.Default));
|
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, Realm, null, audio, Resources, host, Beatmap.Default));
|
||||||
Dependencies.Cache(new ScoreManager(rulesets, () => beatmaps, LocalStorage, Realm, Scheduler, API));
|
Dependencies.Cache(new ScoreManager(rulesets, () => beatmaps, LocalStorage, Realm, API));
|
||||||
Dependencies.Cache(Realm);
|
Dependencies.Cache(Realm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
private const double skip_time = 6000;
|
private const double skip_time = 6000;
|
||||||
|
|
||||||
[SetUp]
|
private void createTest(double skipTime = skip_time) => AddStep("create test", () =>
|
||||||
public void SetUp() => Schedule(() =>
|
|
||||||
{
|
{
|
||||||
requestCount = 0;
|
requestCount = 0;
|
||||||
increment = skip_time;
|
increment = skip_time;
|
||||||
@ -40,7 +39,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
skip = new TestSkipOverlay(skip_time)
|
skip = new TestSkipOverlay(skipTime)
|
||||||
{
|
{
|
||||||
RequestSkip = () =>
|
RequestSkip = () =>
|
||||||
{
|
{
|
||||||
@ -55,9 +54,25 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
gameplayClock = gameplayClockContainer;
|
gameplayClock = gameplayClockContainer;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSkipTimeZero()
|
||||||
|
{
|
||||||
|
createTest(0);
|
||||||
|
AddUntilStep("wait for skip overlay expired", () => !skip.IsAlive);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSkipTimeEqualToSkip()
|
||||||
|
{
|
||||||
|
createTest(MasterGameplayClockContainer.MINIMUM_SKIP_TIME);
|
||||||
|
AddUntilStep("wait for skip overlay expired", () => !skip.IsAlive);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestFadeOnIdle()
|
public void TestFadeOnIdle()
|
||||||
{
|
{
|
||||||
|
createTest();
|
||||||
|
|
||||||
AddStep("move mouse", () => InputManager.MoveMouseTo(Vector2.Zero));
|
AddStep("move mouse", () => InputManager.MoveMouseTo(Vector2.Zero));
|
||||||
AddUntilStep("fully visible", () => skip.FadingContent.Alpha == 1);
|
AddUntilStep("fully visible", () => skip.FadingContent.Alpha == 1);
|
||||||
AddUntilStep("wait for fade", () => skip.FadingContent.Alpha < 1);
|
AddUntilStep("wait for fade", () => skip.FadingContent.Alpha < 1);
|
||||||
@ -70,6 +85,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestClickableAfterFade()
|
public void TestClickableAfterFade()
|
||||||
{
|
{
|
||||||
|
createTest();
|
||||||
|
|
||||||
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||||
AddUntilStep("wait for fade", () => skip.FadingContent.Alpha == 0);
|
AddUntilStep("wait for fade", () => skip.FadingContent.Alpha == 0);
|
||||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
@ -79,6 +96,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestClickOnlyActuatesOnce()
|
public void TestClickOnlyActuatesOnce()
|
||||||
{
|
{
|
||||||
|
createTest();
|
||||||
|
|
||||||
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||||
AddStep("click", () =>
|
AddStep("click", () =>
|
||||||
{
|
{
|
||||||
@ -94,6 +113,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestClickOnlyActuatesMultipleTimes()
|
public void TestClickOnlyActuatesMultipleTimes()
|
||||||
{
|
{
|
||||||
|
createTest();
|
||||||
|
|
||||||
AddStep("set increment lower", () => increment = 3000);
|
AddStep("set increment lower", () => increment = 3000);
|
||||||
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||||
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
AddStep("click", () => InputManager.Click(MouseButton.Left));
|
||||||
@ -106,6 +127,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestDoesntFadeOnMouseDown()
|
public void TestDoesntFadeOnMouseDown()
|
||||||
{
|
{
|
||||||
|
createTest();
|
||||||
|
|
||||||
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
AddStep("move mouse", () => InputManager.MoveMouseTo(skip.ScreenSpaceDrawQuad.Centre));
|
||||||
AddStep("button down", () => InputManager.PressButton(MouseButton.Left));
|
AddStep("button down", () => InputManager.PressButton(MouseButton.Left));
|
||||||
AddUntilStep("wait for overlay disappear", () => !skip.OverlayContent.IsPresent);
|
AddUntilStep("wait for overlay disappear", () => !skip.OverlayContent.IsPresent);
|
||||||
|
@ -52,6 +52,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
},
|
},
|
||||||
notifications = new NotificationOverlay
|
notifications = new NotificationOverlay
|
||||||
{
|
{
|
||||||
|
Depth = float.MinValue,
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
}
|
}
|
||||||
@ -82,7 +83,14 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
[Test]
|
[Test]
|
||||||
public virtual void TestPlayIntroWithFailingAudioDevice()
|
public virtual void TestPlayIntroWithFailingAudioDevice()
|
||||||
{
|
{
|
||||||
AddStep("hide notifications", () => notifications.Hide());
|
AddStep("reset notifications", () =>
|
||||||
|
{
|
||||||
|
notifications.Show();
|
||||||
|
notifications.Hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for no notifications", () => notifications.UnreadCount.Value, () => Is.EqualTo(0));
|
||||||
|
|
||||||
AddStep("restart sequence", () =>
|
AddStep("restart sequence", () =>
|
||||||
{
|
{
|
||||||
logo.FinishTransforms();
|
logo.FinishTransforms();
|
||||||
|
@ -26,16 +26,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
public void TestImportantNotificationDoesntInterruptSetup()
|
public void TestImportantNotificationDoesntInterruptSetup()
|
||||||
{
|
{
|
||||||
AddStep("post important notification", () => Game.Notifications.Post(new SimpleNotification { Text = "Important notification" }));
|
AddStep("post important notification", () => Game.Notifications.Post(new SimpleNotification { Text = "Important notification" }));
|
||||||
AddAssert("no notification posted", () => Game.Notifications.UnreadCount.Value == 0);
|
|
||||||
AddAssert("first-run setup still visible", () => Game.FirstRunOverlay.State.Value == Visibility.Visible);
|
AddAssert("first-run setup still visible", () => Game.FirstRunOverlay.State.Value == Visibility.Visible);
|
||||||
|
|
||||||
AddUntilStep("finish first-run setup", () =>
|
|
||||||
{
|
|
||||||
Game.FirstRunOverlay.NextButton.TriggerClick();
|
|
||||||
return Game.FirstRunOverlay.State.Value == Visibility.Hidden;
|
|
||||||
});
|
|
||||||
AddWaitStep("wait for post delay", 5);
|
|
||||||
AddAssert("notifications shown", () => Game.Notifications.State.Value == Visibility.Visible);
|
|
||||||
AddAssert("notification posted", () => Game.Notifications.UnreadCount.Value == 1);
|
AddAssert("notification posted", () => Game.Notifications.UnreadCount.Value == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
userScore = TestResources.CreateTestScoreInfo();
|
userScore = TestResources.CreateTestScoreInfo();
|
||||||
userScore.TotalScore = 0;
|
userScore.TotalScore = 0;
|
||||||
userScore.Statistics = new Dictionary<HitResult, int>();
|
userScore.Statistics = new Dictionary<HitResult, int>();
|
||||||
|
userScore.MaximumStatistics = new Dictionary<HitResult, int>();
|
||||||
|
|
||||||
bindHandler();
|
bindHandler();
|
||||||
|
|
||||||
|
@ -494,6 +494,43 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddAssert("Something is selected", () => carousel.SelectedBeatmapInfo != null);
|
AddAssert("Something is selected", () => carousel.SelectedBeatmapInfo != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSortingDateSubmitted()
|
||||||
|
{
|
||||||
|
var sets = new List<BeatmapSetInfo>();
|
||||||
|
const string zzz_string = "zzzzz";
|
||||||
|
|
||||||
|
AddStep("Populuate beatmap sets", () =>
|
||||||
|
{
|
||||||
|
sets.Clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < 20; i++)
|
||||||
|
{
|
||||||
|
var set = TestResources.CreateTestBeatmapSetInfo(5);
|
||||||
|
|
||||||
|
if (i >= 2 && i < 10)
|
||||||
|
set.DateSubmitted = DateTimeOffset.Now.AddMinutes(i);
|
||||||
|
if (i < 5)
|
||||||
|
set.Beatmaps.ForEach(b => b.Metadata.Artist = zzz_string);
|
||||||
|
|
||||||
|
sets.Add(set);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
loadBeatmaps(sets);
|
||||||
|
|
||||||
|
AddStep("Sort by date submitted", () => carousel.Filter(new FilterCriteria { Sort = SortMode.DateSubmitted }, false));
|
||||||
|
checkVisibleItemCount(diff: false, count: 8);
|
||||||
|
checkVisibleItemCount(diff: true, count: 5);
|
||||||
|
AddStep("Sort by date submitted and string", () => carousel.Filter(new FilterCriteria
|
||||||
|
{
|
||||||
|
Sort = SortMode.DateSubmitted,
|
||||||
|
SearchText = zzz_string
|
||||||
|
}, false));
|
||||||
|
checkVisibleItemCount(diff: false, count: 3);
|
||||||
|
checkVisibleItemCount(diff: true, count: 5);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSorting()
|
public void TestSorting()
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
dependencies.Cache(rulesetStore = new RealmRulesetStore(Realm));
|
dependencies.Cache(rulesetStore = new RealmRulesetStore(Realm));
|
||||||
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), Beatmap.Default));
|
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), Beatmap.Default));
|
||||||
dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, Realm, Scheduler, API));
|
dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, Realm, API));
|
||||||
Dependencies.Cache(Realm);
|
Dependencies.Cache(Realm);
|
||||||
|
|
||||||
return dependencies;
|
return dependencies;
|
||||||
|
@ -6,15 +6,18 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
@ -24,6 +27,7 @@ using osu.Game.Online.API.Requests.Responses;
|
|||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Mods;
|
using osu.Game.Overlays.Mods;
|
||||||
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
@ -413,6 +417,55 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmapInfo == null);
|
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmapInfo == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSelectionRetainedOnBeatmapUpdate()
|
||||||
|
{
|
||||||
|
createSongSelect();
|
||||||
|
changeRuleset(0);
|
||||||
|
|
||||||
|
Live<BeatmapSetInfo> original = null!;
|
||||||
|
int originalOnlineSetID = 0;
|
||||||
|
|
||||||
|
AddStep(@"Sort by artist", () => config.SetValue(OsuSetting.SongSelectSortingMode, SortMode.Artist));
|
||||||
|
|
||||||
|
AddStep("import original", () =>
|
||||||
|
{
|
||||||
|
original = manager.Import(new ImportTask(TestResources.GetQuickTestBeatmapForImport())).GetResultSafely();
|
||||||
|
originalOnlineSetID = original!.Value.OnlineID;
|
||||||
|
});
|
||||||
|
|
||||||
|
// This will move the beatmap set to a different location in the carousel.
|
||||||
|
AddStep("Update original with bogus info", () =>
|
||||||
|
{
|
||||||
|
original.PerformWrite(set =>
|
||||||
|
{
|
||||||
|
foreach (var beatmap in set.Beatmaps)
|
||||||
|
{
|
||||||
|
beatmap.Metadata.Artist = "ZZZZZ";
|
||||||
|
beatmap.OnlineID = 12804;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AddRepeatStep("import other beatmaps", () =>
|
||||||
|
{
|
||||||
|
var testBeatmapSetInfo = TestResources.CreateTestBeatmapSetInfo();
|
||||||
|
|
||||||
|
foreach (var beatmap in testBeatmapSetInfo.Beatmaps)
|
||||||
|
beatmap.Metadata.Artist = ((char)RNG.Next('A', 'Z')).ToString();
|
||||||
|
|
||||||
|
manager.Import(testBeatmapSetInfo);
|
||||||
|
}, 10);
|
||||||
|
|
||||||
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo?.BeatmapSet?.OnlineID == originalOnlineSetID);
|
||||||
|
|
||||||
|
Task<Live<BeatmapSetInfo>> updateTask = null!;
|
||||||
|
AddStep("update beatmap", () => updateTask = manager.ImportAsUpdate(new ProgressNotification(), new ImportTask(TestResources.GetQuickTestBeatmapForImport()), original.Value));
|
||||||
|
AddUntilStep("wait for update completion", () => updateTask.IsCompleted);
|
||||||
|
|
||||||
|
AddUntilStep("retained selection", () => songSelect.Carousel.SelectedBeatmapInfo?.BeatmapSet?.OnlineID == originalOnlineSetID);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestPresentNewRulesetNewBeatmap()
|
public void TestPresentNewRulesetNewBeatmap()
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
||||||
Dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, null, audio, Resources, host, Beatmap.Default));
|
Dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, null, audio, Resources, host, Beatmap.Default));
|
||||||
Dependencies.Cache(scoreManager = new ScoreManager(rulesets, () => beatmapManager, LocalStorage, Realm, Scheduler, API));
|
Dependencies.Cache(scoreManager = new ScoreManager(rulesets, () => beatmapManager, LocalStorage, Realm, API));
|
||||||
Dependencies.Cache(Realm);
|
Dependencies.Cache(Realm);
|
||||||
|
|
||||||
beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
|
beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
|
||||||
|
@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
dependencies.Cache(new RealmRulesetStore(Realm));
|
dependencies.Cache(new RealmRulesetStore(Realm));
|
||||||
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), Beatmap.Default));
|
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, Realm, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), Beatmap.Default));
|
||||||
dependencies.Cache(scoreManager = new ScoreManager(dependencies.Get<RulesetStore>(), () => beatmapManager, LocalStorage, Realm, Scheduler, API));
|
dependencies.Cache(scoreManager = new ScoreManager(dependencies.Get<RulesetStore>(), () => beatmapManager, LocalStorage, Realm, API));
|
||||||
Dependencies.Cache(Realm);
|
Dependencies.Cache(Realm);
|
||||||
|
|
||||||
return dependencies;
|
return dependencies;
|
||||||
|
@ -194,7 +194,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
AddStep("notification arrived", () => notificationOverlay.Verify(n => n.Post(It.IsAny<Notification>()), Times.Once));
|
AddStep("notification arrived", () => notificationOverlay.Verify(n => n.Post(It.IsAny<Notification>()), Times.Once));
|
||||||
|
|
||||||
AddStep("run notification action", () => lastNotification.Activated());
|
AddStep("run notification action", () => lastNotification.Activated?.Invoke());
|
||||||
|
|
||||||
AddAssert("overlay shown", () => overlay.State.Value == Visibility.Visible);
|
AddAssert("overlay shown", () => overlay.State.Value == Visibility.Visible);
|
||||||
AddAssert("is resumed", () => overlay.CurrentScreen is ScreenUIScale);
|
AddAssert("is resumed", () => overlay.CurrentScreen is ScreenUIScale);
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -19,11 +17,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneNotificationOverlay : OsuTestScene
|
public class TestSceneNotificationOverlay : OsuTestScene
|
||||||
{
|
{
|
||||||
private NotificationOverlay notificationOverlay;
|
private NotificationOverlay notificationOverlay = null!;
|
||||||
|
|
||||||
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
|
private readonly List<ProgressNotification> progressingNotifications = new List<ProgressNotification>();
|
||||||
|
|
||||||
private SpriteText displayedCount;
|
private SpriteText displayedCount = null!;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp() => Schedule(() =>
|
public void SetUp() => Schedule(() =>
|
||||||
@ -46,7 +44,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestCompleteProgress()
|
public void TestCompleteProgress()
|
||||||
{
|
{
|
||||||
ProgressNotification notification = null;
|
ProgressNotification notification = null!;
|
||||||
AddStep("add progress notification", () =>
|
AddStep("add progress notification", () =>
|
||||||
{
|
{
|
||||||
notification = new ProgressNotification
|
notification = new ProgressNotification
|
||||||
@ -64,7 +62,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestCancelProgress()
|
public void TestCancelProgress()
|
||||||
{
|
{
|
||||||
ProgressNotification notification = null;
|
ProgressNotification notification = null!;
|
||||||
AddStep("add progress notification", () =>
|
AddStep("add progress notification", () =>
|
||||||
{
|
{
|
||||||
notification = new ProgressNotification
|
notification = new ProgressNotification
|
||||||
@ -112,7 +110,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
{
|
{
|
||||||
AddStep(@"simple #1", sendHelloNotification);
|
AddStep(@"simple #1", sendHelloNotification);
|
||||||
|
|
||||||
AddAssert("Is visible", () => notificationOverlay.State.Value == Visibility.Visible);
|
AddAssert("toast displayed", () => notificationOverlay.ToastCount == 1);
|
||||||
|
AddAssert("is not visible", () => notificationOverlay.State.Value == Visibility.Hidden);
|
||||||
|
|
||||||
checkDisplayedCount(1);
|
checkDisplayedCount(1);
|
||||||
|
|
||||||
@ -185,7 +184,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkDisplayedCount(int expected) =>
|
private void checkDisplayedCount(int expected) =>
|
||||||
AddAssert($"Displayed count is {expected}", () => notificationOverlay.UnreadCount.Value == expected);
|
AddUntilStep($"Displayed count is {expected}", () => notificationOverlay.UnreadCount.Value == expected);
|
||||||
|
|
||||||
private void sendDownloadProgress()
|
private void sendDownloadProgress()
|
||||||
{
|
{
|
||||||
|
@ -40,5 +40,7 @@ namespace osu.Game.Tournament.Models
|
|||||||
MinValue = 3,
|
MinValue = 3,
|
||||||
MaxValue = 4,
|
MaxValue = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public Bindable<bool> AutoProgressScreens = new BindableBool(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 osu.Framework.Extensions.ObjectExtensions;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
@ -41,7 +40,7 @@ namespace osu.Game.Tournament.Models
|
|||||||
StarRating = beatmap.StarRating;
|
StarRating = beatmap.StarRating;
|
||||||
Metadata = beatmap.Metadata;
|
Metadata = beatmap.Metadata;
|
||||||
Difficulty = beatmap.Difficulty;
|
Difficulty = beatmap.Difficulty;
|
||||||
Covers = beatmap.BeatmapSet.AsNonNull().Covers;
|
Covers = beatmap.BeatmapSet?.Covers ?? new BeatmapSetOnlineCovers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(IBeatmapInfo? other) => other is TournamentBeatmap b && this.MatchesOnlineID(b);
|
public bool Equals(IBeatmapInfo? other) => other is TournamentBeatmap b && this.MatchesOnlineID(b);
|
||||||
|
@ -199,16 +199,19 @@ namespace osu.Game.Tournament.Screens.Gameplay
|
|||||||
case TourneyState.Idle:
|
case TourneyState.Idle:
|
||||||
contract();
|
contract();
|
||||||
|
|
||||||
const float delay_before_progression = 4000;
|
if (LadderInfo.AutoProgressScreens.Value)
|
||||||
|
|
||||||
// if we've returned to idle and the last screen was ranking
|
|
||||||
// we should automatically proceed after a short delay
|
|
||||||
if (lastState == TourneyState.Ranking && !warmup.Value)
|
|
||||||
{
|
{
|
||||||
if (CurrentMatch.Value?.Completed.Value == true)
|
const float delay_before_progression = 4000;
|
||||||
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(TeamWinScreen)); }, delay_before_progression);
|
|
||||||
else if (CurrentMatch.Value?.Completed.Value == false)
|
// if we've returned to idle and the last screen was ranking
|
||||||
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(MapPoolScreen)); }, delay_before_progression);
|
// we should automatically proceed after a short delay
|
||||||
|
if (lastState == TourneyState.Ranking && !warmup.Value)
|
||||||
|
{
|
||||||
|
if (CurrentMatch.Value?.Completed.Value == true)
|
||||||
|
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(TeamWinScreen)); }, delay_before_progression);
|
||||||
|
else if (CurrentMatch.Value?.Completed.Value == false)
|
||||||
|
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(MapPoolScreen)); }, delay_before_progression);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -197,10 +197,13 @@ namespace osu.Game.Tournament.Screens.MapPool
|
|||||||
|
|
||||||
setNextMode();
|
setNextMode();
|
||||||
|
|
||||||
if (pickType == ChoiceType.Pick && CurrentMatch.Value.PicksBans.Any(i => i.Type == ChoiceType.Pick))
|
if (LadderInfo.AutoProgressScreens.Value)
|
||||||
{
|
{
|
||||||
scheduledChange?.Cancel();
|
if (pickType == ChoiceType.Pick && CurrentMatch.Value.PicksBans.Any(i => i.Type == ChoiceType.Pick))
|
||||||
scheduledChange = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(GameplayScreen)); }, 10000);
|
{
|
||||||
|
scheduledChange?.Cancel();
|
||||||
|
scheduledChange = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(GameplayScreen)); }, 10000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +131,12 @@ namespace osu.Game.Tournament.Screens.Setup
|
|||||||
windowSize.Value = new Size((int)(height * aspect_ratio / TournamentSceneManager.STREAM_AREA_WIDTH * TournamentSceneManager.REQUIRED_WIDTH), height);
|
windowSize.Value = new Size((int)(height * aspect_ratio / TournamentSceneManager.STREAM_AREA_WIDTH * TournamentSceneManager.REQUIRED_WIDTH), height);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
new LabelledSwitchButton
|
||||||
|
{
|
||||||
|
Label = "Auto advance screens",
|
||||||
|
Description = "Screens will progress automatically from gameplay -> results -> map pool",
|
||||||
|
Current = LadderInfo.AutoProgressScreens,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,14 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
// If there were no changes, ensure we don't accidentally nuke ourselves.
|
// If there were no changes, ensure we don't accidentally nuke ourselves.
|
||||||
if (first.ID == original.ID)
|
if (first.ID == original.ID)
|
||||||
|
{
|
||||||
|
first.PerformRead(s =>
|
||||||
|
{
|
||||||
|
// Re-run processing even in this case. We might have outdated metadata.
|
||||||
|
ProcessBeatmap?.Invoke((s, false));
|
||||||
|
});
|
||||||
return first;
|
return first;
|
||||||
|
}
|
||||||
|
|
||||||
first.PerformWrite(updated =>
|
first.PerformWrite(updated =>
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
|
@ -373,7 +373,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
string[] split = line.Split(',');
|
string[] split = line.Split(',');
|
||||||
|
|
||||||
double time = getOffsetTime(Parsing.ParseDouble(split[0].Trim()));
|
double time = getOffsetTime(Parsing.ParseDouble(split[0].Trim()));
|
||||||
double beatLength = Parsing.ParseDouble(split[1].Trim());
|
|
||||||
|
// beatLength is allowed to be NaN to handle an edge case in which some beatmaps use NaN slider velocity to disable slider tick generation (see LegacyDifficultyControlPoint).
|
||||||
|
double beatLength = Parsing.ParseDouble(split[1].Trim(), allowNaN: true);
|
||||||
|
|
||||||
|
// If beatLength is NaN, speedMultiplier should still be 1 because all comparisons against NaN are false.
|
||||||
double speedMultiplier = beatLength < 0 ? 100.0 / -beatLength : 1;
|
double speedMultiplier = beatLength < 0 ? 100.0 / -beatLength : 1;
|
||||||
|
|
||||||
TimeSignature timeSignature = TimeSignature.SimpleQuadruple;
|
TimeSignature timeSignature = TimeSignature.SimpleQuadruple;
|
||||||
@ -412,6 +416,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
if (timingChange)
|
if (timingChange)
|
||||||
{
|
{
|
||||||
|
if (double.IsNaN(beatLength))
|
||||||
|
throw new InvalidDataException("Beat length cannot be NaN in a timing control point");
|
||||||
|
|
||||||
var controlPoint = CreateTimingControlPoint();
|
var controlPoint = CreateTimingControlPoint();
|
||||||
|
|
||||||
controlPoint.BeatLength = beatLength;
|
controlPoint.BeatLength = beatLength;
|
||||||
|
@ -168,11 +168,18 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double BpmMultiplier { get; private set; }
|
public double BpmMultiplier { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether or not slider ticks should be generated at this control point.
|
||||||
|
/// This exists for backwards compatibility with maps that abuse NaN slider velocity behavior on osu!stable (e.g. /b/2628991).
|
||||||
|
/// </summary>
|
||||||
|
public bool GenerateTicks { get; private set; } = true;
|
||||||
|
|
||||||
public LegacyDifficultyControlPoint(double beatLength)
|
public LegacyDifficultyControlPoint(double beatLength)
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
// Note: In stable, the division occurs on floats, but with compiler optimisations turned on actually seems to occur on doubles via some .NET black magic (possibly inlining?).
|
// Note: In stable, the division occurs on floats, but with compiler optimisations turned on actually seems to occur on doubles via some .NET black magic (possibly inlining?).
|
||||||
BpmMultiplier = beatLength < 0 ? Math.Clamp((float)-beatLength, 10, 10000) / 100.0 : 1;
|
BpmMultiplier = beatLength < 0 ? Math.Clamp((float)-beatLength, 10, 10000) / 100.0 : 1;
|
||||||
|
GenerateTicks = !double.IsNaN(beatLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LegacyDifficultyControlPoint()
|
public LegacyDifficultyControlPoint()
|
||||||
@ -180,11 +187,16 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
SliderVelocityBindable.Precision = double.Epsilon;
|
SliderVelocityBindable.Precision = double.Epsilon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool IsRedundant(ControlPoint? existing)
|
||||||
|
=> base.IsRedundant(existing)
|
||||||
|
&& GenerateTicks == ((existing as LegacyDifficultyControlPoint)?.GenerateTicks ?? true);
|
||||||
|
|
||||||
public override void CopyFrom(ControlPoint other)
|
public override void CopyFrom(ControlPoint other)
|
||||||
{
|
{
|
||||||
base.CopyFrom(other);
|
base.CopyFrom(other);
|
||||||
|
|
||||||
BpmMultiplier = ((LegacyDifficultyControlPoint)other).BpmMultiplier;
|
BpmMultiplier = ((LegacyDifficultyControlPoint)other).BpmMultiplier;
|
||||||
|
GenerateTicks = ((LegacyDifficultyControlPoint)other).GenerateTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(ControlPoint? other)
|
public override bool Equals(ControlPoint? other)
|
||||||
@ -193,10 +205,11 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
public bool Equals(LegacyDifficultyControlPoint? other)
|
public bool Equals(LegacyDifficultyControlPoint? other)
|
||||||
=> base.Equals(other)
|
=> base.Equals(other)
|
||||||
&& BpmMultiplier == other.BpmMultiplier;
|
&& BpmMultiplier == other.BpmMultiplier
|
||||||
|
&& GenerateTicks == other.GenerateTicks;
|
||||||
|
|
||||||
// ReSharper disable once NonReadonlyMemberInGetHashCode
|
// ReSharper disable twice NonReadonlyMemberInGetHashCode
|
||||||
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), BpmMultiplier);
|
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), BpmMultiplier, GenerateTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class LegacySampleControlPoint : SampleControlPoint, IEquatable<LegacySampleControlPoint>
|
internal class LegacySampleControlPoint : SampleControlPoint, IEquatable<LegacySampleControlPoint>
|
||||||
|
@ -17,26 +17,26 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
public const double MAX_PARSE_VALUE = int.MaxValue;
|
public const double MAX_PARSE_VALUE = int.MaxValue;
|
||||||
|
|
||||||
public static float ParseFloat(string input, float parseLimit = (float)MAX_PARSE_VALUE)
|
public static float ParseFloat(string input, float parseLimit = (float)MAX_PARSE_VALUE, bool allowNaN = false)
|
||||||
{
|
{
|
||||||
float output = float.Parse(input, CultureInfo.InvariantCulture);
|
float output = float.Parse(input, CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
if (output < -parseLimit) throw new OverflowException("Value is too low");
|
if (output < -parseLimit) throw new OverflowException("Value is too low");
|
||||||
if (output > parseLimit) throw new OverflowException("Value is too high");
|
if (output > parseLimit) throw new OverflowException("Value is too high");
|
||||||
|
|
||||||
if (float.IsNaN(output)) throw new FormatException("Not a number");
|
if (!allowNaN && float.IsNaN(output)) throw new FormatException("Not a number");
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double ParseDouble(string input, double parseLimit = MAX_PARSE_VALUE)
|
public static double ParseDouble(string input, double parseLimit = MAX_PARSE_VALUE, bool allowNaN = false)
|
||||||
{
|
{
|
||||||
double output = double.Parse(input, CultureInfo.InvariantCulture);
|
double output = double.Parse(input, CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
if (output < -parseLimit) throw new OverflowException("Value is too low");
|
if (output < -parseLimit) throw new OverflowException("Value is too low");
|
||||||
if (output > parseLimit) throw new OverflowException("Value is too high");
|
if (output > parseLimit) throw new OverflowException("Value is too high");
|
||||||
|
|
||||||
if (double.IsNaN(output)) throw new FormatException("Not a number");
|
if (!allowNaN && double.IsNaN(output)) throw new FormatException("Not a number");
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ namespace osu.Game.Beatmaps
|
|||||||
finalClockSource.ProcessFrame();
|
finalClockSource.ProcessFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
private double totalAppliedOffset
|
public double TotalAppliedOffset
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@ -169,7 +169,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public bool Seek(double position)
|
public bool Seek(double position)
|
||||||
{
|
{
|
||||||
bool success = decoupledClock.Seek(position - totalAppliedOffset);
|
bool success = decoupledClock.Seek(position - TotalAppliedOffset);
|
||||||
finalClockSource.ProcessFrame();
|
finalClockSource.ProcessFrame();
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
|
|
||||||
namespace osu.Game.Database
|
namespace osu.Game.Database
|
||||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Database
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
IconBackground.Colour = colours.RedDark;
|
IconContent.Colour = colours.RedDark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,21 +38,19 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
private void load(OsuConfigManager config, SessionStatics sessionStatics)
|
private void load(OsuConfigManager config, SessionStatics sessionStatics)
|
||||||
{
|
{
|
||||||
seasonalBackgroundMode = config.GetBindable<SeasonalBackgroundMode>(OsuSetting.SeasonalBackgroundMode);
|
seasonalBackgroundMode = config.GetBindable<SeasonalBackgroundMode>(OsuSetting.SeasonalBackgroundMode);
|
||||||
seasonalBackgroundMode.BindValueChanged(_ => triggerSeasonalBackgroundChanged());
|
seasonalBackgroundMode.BindValueChanged(_ => SeasonalBackgroundChanged?.Invoke());
|
||||||
|
|
||||||
seasonalBackgrounds = sessionStatics.GetBindable<APISeasonalBackgrounds>(Static.SeasonalBackgrounds);
|
seasonalBackgrounds = sessionStatics.GetBindable<APISeasonalBackgrounds>(Static.SeasonalBackgrounds);
|
||||||
seasonalBackgrounds.BindValueChanged(_ => triggerSeasonalBackgroundChanged());
|
seasonalBackgrounds.BindValueChanged(_ =>
|
||||||
|
{
|
||||||
|
if (shouldShowSeasonal)
|
||||||
|
SeasonalBackgroundChanged?.Invoke();
|
||||||
|
});
|
||||||
|
|
||||||
apiState.BindTo(api.State);
|
apiState.BindTo(api.State);
|
||||||
apiState.BindValueChanged(fetchSeasonalBackgrounds, true);
|
apiState.BindValueChanged(fetchSeasonalBackgrounds, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void triggerSeasonalBackgroundChanged()
|
|
||||||
{
|
|
||||||
if (shouldShowSeasonal)
|
|
||||||
SeasonalBackgroundChanged?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fetchSeasonalBackgrounds(ValueChangedEvent<APIState> stateChanged)
|
private void fetchSeasonalBackgrounds(ValueChangedEvent<APIState> stateChanged)
|
||||||
{
|
{
|
||||||
if (seasonalBackgrounds.Value != null || stateChanged.NewValue != APIState.Online)
|
if (seasonalBackgrounds.Value != null || stateChanged.NewValue != APIState.Online)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
@ -40,30 +42,27 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Margin = new MarginPadding { Left = 2 },
|
Margin = new MarginPadding { Left = 2 },
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly Sample?[] textAddedSamples = new Sample[4];
|
|
||||||
private Sample? capsTextAddedSample;
|
|
||||||
private Sample? textRemovedSample;
|
|
||||||
private Sample? textCommittedSample;
|
|
||||||
private Sample? caretMovedSample;
|
|
||||||
|
|
||||||
private Sample? selectCharSample;
|
|
||||||
private Sample? selectWordSample;
|
|
||||||
private Sample? selectAllSample;
|
|
||||||
private Sample? deselectSample;
|
|
||||||
|
|
||||||
private OsuCaret? caret;
|
private OsuCaret? caret;
|
||||||
|
|
||||||
private bool selectionStarted;
|
private bool selectionStarted;
|
||||||
private double sampleLastPlaybackTime;
|
private double sampleLastPlaybackTime;
|
||||||
|
|
||||||
private enum SelectionSampleType
|
private enum FeedbackSampleType
|
||||||
{
|
{
|
||||||
Character,
|
TextAdd,
|
||||||
Word,
|
TextAddCaps,
|
||||||
All,
|
TextRemove,
|
||||||
|
TextConfirm,
|
||||||
|
TextInvalid,
|
||||||
|
CaretMove,
|
||||||
|
SelectCharacter,
|
||||||
|
SelectWord,
|
||||||
|
SelectAll,
|
||||||
Deselect
|
Deselect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Dictionary<FeedbackSampleType, Sample?[]> sampleMap = new Dictionary<FeedbackSampleType, Sample?[]>();
|
||||||
|
|
||||||
public OsuTextBox()
|
public OsuTextBox()
|
||||||
{
|
{
|
||||||
Height = 40;
|
Height = 40;
|
||||||
@ -87,18 +86,23 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
Placeholder.Colour = colourProvider?.Foreground1 ?? new Color4(180, 180, 180, 255);
|
Placeholder.Colour = colourProvider?.Foreground1 ?? new Color4(180, 180, 180, 255);
|
||||||
|
|
||||||
|
var textAddedSamples = new Sample?[4];
|
||||||
for (int i = 0; i < textAddedSamples.Length; i++)
|
for (int i = 0; i < textAddedSamples.Length; i++)
|
||||||
textAddedSamples[i] = audio.Samples.Get($@"Keyboard/key-press-{1 + i}");
|
textAddedSamples[i] = audio.Samples.Get($@"Keyboard/key-press-{1 + i}");
|
||||||
|
|
||||||
capsTextAddedSample = audio.Samples.Get(@"Keyboard/key-caps");
|
sampleMap = new Dictionary<FeedbackSampleType, Sample?[]>
|
||||||
textRemovedSample = audio.Samples.Get(@"Keyboard/key-delete");
|
{
|
||||||
textCommittedSample = audio.Samples.Get(@"Keyboard/key-confirm");
|
{ FeedbackSampleType.TextAdd, textAddedSamples },
|
||||||
caretMovedSample = audio.Samples.Get(@"Keyboard/key-movement");
|
{ FeedbackSampleType.TextAddCaps, new[] { audio.Samples.Get(@"Keyboard/key-caps") } },
|
||||||
|
{ FeedbackSampleType.TextRemove, new[] { audio.Samples.Get(@"Keyboard/key-delete") } },
|
||||||
selectCharSample = audio.Samples.Get(@"Keyboard/select-char");
|
{ FeedbackSampleType.TextConfirm, new[] { audio.Samples.Get(@"Keyboard/key-confirm") } },
|
||||||
selectWordSample = audio.Samples.Get(@"Keyboard/select-word");
|
{ FeedbackSampleType.TextInvalid, new[] { audio.Samples.Get(@"Keyboard/key-invalid") } },
|
||||||
selectAllSample = audio.Samples.Get(@"Keyboard/select-all");
|
{ FeedbackSampleType.CaretMove, new[] { audio.Samples.Get(@"Keyboard/key-movement") } },
|
||||||
deselectSample = audio.Samples.Get(@"Keyboard/deselect");
|
{ FeedbackSampleType.SelectCharacter, new[] { audio.Samples.Get(@"Keyboard/select-char") } },
|
||||||
|
{ FeedbackSampleType.SelectWord, new[] { audio.Samples.Get(@"Keyboard/select-word") } },
|
||||||
|
{ FeedbackSampleType.SelectAll, new[] { audio.Samples.Get(@"Keyboard/select-all") } },
|
||||||
|
{ FeedbackSampleType.Deselect, new[] { audio.Samples.Get(@"Keyboard/deselect") } }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private Color4 selectionColour;
|
private Color4 selectionColour;
|
||||||
@ -109,24 +113,34 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
base.OnUserTextAdded(added);
|
base.OnUserTextAdded(added);
|
||||||
|
|
||||||
|
if (!added.Any(CanAddCharacter))
|
||||||
|
return;
|
||||||
|
|
||||||
if (added.Any(char.IsUpper) && AllowUniqueCharacterSamples)
|
if (added.Any(char.IsUpper) && AllowUniqueCharacterSamples)
|
||||||
capsTextAddedSample?.Play();
|
playSample(FeedbackSampleType.TextAddCaps);
|
||||||
else
|
else
|
||||||
playTextAddedSample();
|
playSample(FeedbackSampleType.TextAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnUserTextRemoved(string removed)
|
protected override void OnUserTextRemoved(string removed)
|
||||||
{
|
{
|
||||||
base.OnUserTextRemoved(removed);
|
base.OnUserTextRemoved(removed);
|
||||||
|
|
||||||
textRemovedSample?.Play();
|
playSample(FeedbackSampleType.TextRemove);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void NotifyInputError()
|
||||||
|
{
|
||||||
|
base.NotifyInputError();
|
||||||
|
|
||||||
|
playSample(FeedbackSampleType.TextInvalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnTextCommitted(bool textChanged)
|
protected override void OnTextCommitted(bool textChanged)
|
||||||
{
|
{
|
||||||
base.OnTextCommitted(textChanged);
|
base.OnTextCommitted(textChanged);
|
||||||
|
|
||||||
textCommittedSample?.Play();
|
playSample(FeedbackSampleType.TextConfirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnCaretMoved(bool selecting)
|
protected override void OnCaretMoved(bool selecting)
|
||||||
@ -134,7 +148,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
base.OnCaretMoved(selecting);
|
base.OnCaretMoved(selecting);
|
||||||
|
|
||||||
if (!selecting)
|
if (!selecting)
|
||||||
caretMovedSample?.Play();
|
playSample(FeedbackSampleType.CaretMove);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnTextSelectionChanged(TextSelectionType selectionType)
|
protected override void OnTextSelectionChanged(TextSelectionType selectionType)
|
||||||
@ -144,15 +158,15 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
switch (selectionType)
|
switch (selectionType)
|
||||||
{
|
{
|
||||||
case TextSelectionType.Character:
|
case TextSelectionType.Character:
|
||||||
playSelectSample(SelectionSampleType.Character);
|
playSample(FeedbackSampleType.SelectCharacter);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TextSelectionType.Word:
|
case TextSelectionType.Word:
|
||||||
playSelectSample(selectionStarted ? SelectionSampleType.Character : SelectionSampleType.Word);
|
playSample(selectionStarted ? FeedbackSampleType.SelectCharacter : FeedbackSampleType.SelectWord);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TextSelectionType.All:
|
case TextSelectionType.All:
|
||||||
playSelectSample(SelectionSampleType.All);
|
playSample(FeedbackSampleType.SelectAll);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +179,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
if (!selectionStarted) return;
|
if (!selectionStarted) return;
|
||||||
|
|
||||||
playSelectSample(SelectionSampleType.Deselect);
|
playSample(FeedbackSampleType.Deselect);
|
||||||
|
|
||||||
selectionStarted = false;
|
selectionStarted = false;
|
||||||
}
|
}
|
||||||
@ -184,13 +198,13 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
// composition probably ended by pressing backspace, or was cancelled.
|
// composition probably ended by pressing backspace, or was cancelled.
|
||||||
textRemovedSample?.Play();
|
playSample(FeedbackSampleType.TextRemove);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// longer text removed, composition ended because it was cancelled.
|
// longer text removed, composition ended because it was cancelled.
|
||||||
// could be a different sample if desired.
|
// could be a different sample if desired.
|
||||||
textRemovedSample?.Play();
|
playSample(FeedbackSampleType.TextRemove);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,7 +212,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
if (addedTextLength > 0)
|
if (addedTextLength > 0)
|
||||||
{
|
{
|
||||||
// some text was added, probably due to typing new text or by changing the candidate.
|
// some text was added, probably due to typing new text or by changing the candidate.
|
||||||
playTextAddedSample();
|
playSample(FeedbackSampleType.TextAdd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,14 +220,14 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
// text was probably removed by backspacing.
|
// text was probably removed by backspacing.
|
||||||
// it's also possible that a candidate that only removed text was changed to.
|
// it's also possible that a candidate that only removed text was changed to.
|
||||||
textRemovedSample?.Play();
|
playSample(FeedbackSampleType.TextRemove);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (caretMoved)
|
if (caretMoved)
|
||||||
{
|
{
|
||||||
// only the caret/selection was moved.
|
// only the caret/selection was moved.
|
||||||
caretMovedSample?.Play();
|
playSample(FeedbackSampleType.CaretMove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,13 +238,13 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
if (successful)
|
if (successful)
|
||||||
{
|
{
|
||||||
// composition was successfully completed, usually by pressing the enter key.
|
// composition was successfully completed, usually by pressing the enter key.
|
||||||
textCommittedSample?.Play();
|
playSample(FeedbackSampleType.TextConfirm);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// composition was prematurely ended, eg. by clicking inside the textbox.
|
// composition was prematurely ended, eg. by clicking inside the textbox.
|
||||||
// could be a different sample if desired.
|
// could be a different sample if desired.
|
||||||
textCommittedSample?.Play();
|
playSample(FeedbackSampleType.TextConfirm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,43 +273,35 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
SelectionColour = SelectionColour,
|
SelectionColour = SelectionColour,
|
||||||
};
|
};
|
||||||
|
|
||||||
private void playSelectSample(SelectionSampleType selectionType)
|
private SampleChannel? getSampleChannel(FeedbackSampleType feedbackSampleType)
|
||||||
|
{
|
||||||
|
var samples = sampleMap[feedbackSampleType];
|
||||||
|
|
||||||
|
if (samples == null || samples.Length == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return samples[RNG.Next(0, samples.Length)]?.GetChannel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playSample(FeedbackSampleType feedbackSample)
|
||||||
{
|
{
|
||||||
if (Time.Current < sampleLastPlaybackTime + 15) return;
|
if (Time.Current < sampleLastPlaybackTime + 15) return;
|
||||||
|
|
||||||
SampleChannel? channel;
|
SampleChannel? channel = getSampleChannel(feedbackSample);
|
||||||
double pitch = 0.98 + RNG.NextDouble(0.04);
|
|
||||||
|
|
||||||
switch (selectionType)
|
|
||||||
{
|
|
||||||
case SelectionSampleType.All:
|
|
||||||
channel = selectAllSample?.GetChannel();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SelectionSampleType.Word:
|
|
||||||
channel = selectWordSample?.GetChannel();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SelectionSampleType.Deselect:
|
|
||||||
channel = deselectSample?.GetChannel();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
channel = selectCharSample?.GetChannel();
|
|
||||||
pitch += (SelectedText.Length / (double)Text.Length) * 0.15f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channel == null) return;
|
if (channel == null) return;
|
||||||
|
|
||||||
|
double pitch = 0.98 + RNG.NextDouble(0.04);
|
||||||
|
|
||||||
|
if (feedbackSample == FeedbackSampleType.SelectCharacter)
|
||||||
|
pitch += ((double)SelectedText.Length / Math.Max(1, Text.Length)) * 0.15f;
|
||||||
|
|
||||||
channel.Frequency.Value = pitch;
|
channel.Frequency.Value = pitch;
|
||||||
channel.Play();
|
channel.Play();
|
||||||
|
|
||||||
sampleLastPlaybackTime = Time.Current;
|
sampleLastPlaybackTime = Time.Current;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playTextAddedSample() => textAddedSamples[RNG.Next(0, textAddedSamples.Length)]?.Play();
|
|
||||||
|
|
||||||
private class OsuCaret : Caret
|
private class OsuCaret : Caret
|
||||||
{
|
{
|
||||||
private const float caret_move_time = 60;
|
private const float caret_move_time = 60;
|
||||||
|
@ -77,6 +77,12 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
[JsonProperty("maximum_statistics")]
|
[JsonProperty("maximum_statistics")]
|
||||||
public Dictionary<HitResult, int> MaximumStatistics { get; set; } = new Dictionary<HitResult, int>();
|
public Dictionary<HitResult, int> MaximumStatistics { get; set; } = new Dictionary<HitResult, int>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used to preserve the total score for legacy scores.
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("legacy_total_score")]
|
||||||
|
public int? LegacyTotalScore { get; set; }
|
||||||
|
|
||||||
#region osu-web API additions (not stored to database).
|
#region osu-web API additions (not stored to database).
|
||||||
|
|
||||||
[JsonProperty("id")]
|
[JsonProperty("id")]
|
||||||
|
@ -174,7 +174,7 @@ namespace osu.Game.Online.Chat
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, ChatOverlay chatOverlay, INotificationOverlay notificationOverlay)
|
private void load(OsuColour colours, ChatOverlay chatOverlay, INotificationOverlay notificationOverlay)
|
||||||
{
|
{
|
||||||
IconBackground.Colour = colours.PurpleDark;
|
IconContent.Colour = colours.PurpleDark;
|
||||||
|
|
||||||
Activated = delegate
|
Activated = delegate
|
||||||
{
|
{
|
||||||
|
@ -265,8 +265,9 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
/// <param name="matchType">The type of the match, if any.</param>
|
/// <param name="matchType">The type of the match, if any.</param>
|
||||||
/// <param name="queueMode">The new queue mode, if any.</param>
|
/// <param name="queueMode">The new queue mode, if any.</param>
|
||||||
/// <param name="autoStartDuration">The new auto-start countdown duration, if any.</param>
|
/// <param name="autoStartDuration">The new auto-start countdown duration, if any.</param>
|
||||||
|
/// <param name="autoSkip">The new auto-skip setting.</param>
|
||||||
public Task ChangeSettings(Optional<string> name = default, Optional<string> password = default, Optional<MatchType> matchType = default, Optional<QueueMode> queueMode = default,
|
public Task ChangeSettings(Optional<string> name = default, Optional<string> password = default, Optional<MatchType> matchType = default, Optional<QueueMode> queueMode = default,
|
||||||
Optional<TimeSpan> autoStartDuration = default)
|
Optional<TimeSpan> autoStartDuration = default, Optional<bool> autoSkip = default)
|
||||||
{
|
{
|
||||||
if (Room == null)
|
if (Room == null)
|
||||||
throw new InvalidOperationException("Must be joined to a match to change settings.");
|
throw new InvalidOperationException("Must be joined to a match to change settings.");
|
||||||
@ -278,6 +279,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
MatchType = matchType.GetOr(Room.Settings.MatchType),
|
MatchType = matchType.GetOr(Room.Settings.MatchType),
|
||||||
QueueMode = queueMode.GetOr(Room.Settings.QueueMode),
|
QueueMode = queueMode.GetOr(Room.Settings.QueueMode),
|
||||||
AutoStartDuration = autoStartDuration.GetOr(Room.Settings.AutoStartDuration),
|
AutoStartDuration = autoStartDuration.GetOr(Room.Settings.AutoStartDuration),
|
||||||
|
AutoSkip = autoSkip.GetOr(Room.Settings.AutoSkip)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -739,6 +741,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
APIRoom.QueueMode.Value = Room.Settings.QueueMode;
|
APIRoom.QueueMode.Value = Room.Settings.QueueMode;
|
||||||
APIRoom.AutoStartDuration.Value = Room.Settings.AutoStartDuration;
|
APIRoom.AutoStartDuration.Value = Room.Settings.AutoStartDuration;
|
||||||
APIRoom.CurrentPlaylistItem.Value = APIRoom.Playlist.Single(item => item.ID == settings.PlaylistItemId);
|
APIRoom.CurrentPlaylistItem.Value = APIRoom.Playlist.Single(item => item.ID == settings.PlaylistItemId);
|
||||||
|
APIRoom.AutoSkip.Value = Room.Settings.AutoSkip;
|
||||||
|
|
||||||
RoomUpdated?.Invoke();
|
RoomUpdated?.Invoke();
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,9 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
[Key(5)]
|
[Key(5)]
|
||||||
public TimeSpan AutoStartDuration { get; set; }
|
public TimeSpan AutoStartDuration { get; set; }
|
||||||
|
|
||||||
|
[Key(6)]
|
||||||
|
public bool AutoSkip { get; set; }
|
||||||
|
|
||||||
[IgnoreMember]
|
[IgnoreMember]
|
||||||
public bool AutoStartEnabled => AutoStartDuration != TimeSpan.Zero;
|
public bool AutoStartEnabled => AutoStartDuration != TimeSpan.Zero;
|
||||||
|
|
||||||
@ -42,7 +45,8 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
&& PlaylistItemId == other.PlaylistItemId
|
&& PlaylistItemId == other.PlaylistItemId
|
||||||
&& MatchType == other.MatchType
|
&& MatchType == other.MatchType
|
||||||
&& QueueMode == other.QueueMode
|
&& QueueMode == other.QueueMode
|
||||||
&& AutoStartDuration == other.AutoStartDuration;
|
&& AutoStartDuration == other.AutoStartDuration
|
||||||
|
&& AutoSkip == other.AutoSkip;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"Name:{Name}"
|
public override string ToString() => $"Name:{Name}"
|
||||||
@ -50,6 +54,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
+ $" Type:{MatchType}"
|
+ $" Type:{MatchType}"
|
||||||
+ $" Item:{PlaylistItemId}"
|
+ $" Item:{PlaylistItemId}"
|
||||||
+ $" Queue:{QueueMode}"
|
+ $" Queue:{QueueMode}"
|
||||||
+ $" Start:{AutoStartDuration}";
|
+ $" Start:{AutoStartDuration}"
|
||||||
|
+ $" AutoSkip:{AutoSkip}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,6 +159,10 @@ namespace osu.Game.Online.Rooms
|
|||||||
set => MaxAttempts.Value = value;
|
set => MaxAttempts.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
[JsonProperty("auto_skip")]
|
||||||
|
public readonly Bindable<bool> AutoSkip = new Bindable<bool>();
|
||||||
|
|
||||||
public Room()
|
public Room()
|
||||||
{
|
{
|
||||||
Password.BindValueChanged(p => HasPassword.Value = !string.IsNullOrEmpty(p.NewValue));
|
Password.BindValueChanged(p => HasPassword.Value = !string.IsNullOrEmpty(p.NewValue));
|
||||||
@ -195,6 +199,7 @@ namespace osu.Game.Online.Rooms
|
|||||||
DifficultyRange.Value = other.DifficultyRange.Value;
|
DifficultyRange.Value = other.DifficultyRange.Value;
|
||||||
PlaylistItemStats.Value = other.PlaylistItemStats.Value;
|
PlaylistItemStats.Value = other.PlaylistItemStats.Value;
|
||||||
CurrentPlaylistItem.Value = other.CurrentPlaylistItem.Value;
|
CurrentPlaylistItem.Value = other.CurrentPlaylistItem.Value;
|
||||||
|
AutoSkip.Value = other.AutoSkip.Value;
|
||||||
|
|
||||||
if (EndDate.Value != null && DateTimeOffset.Now >= EndDate.Value)
|
if (EndDate.Value != null && DateTimeOffset.Now >= EndDate.Value)
|
||||||
Status.Value = new RoomStatusEnded();
|
Status.Value = new RoomStatusEnded();
|
||||||
|
@ -804,8 +804,8 @@ namespace osu.Game
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
overlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
overlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
rightFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
|
||||||
leftFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
leftFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
|
rightFloatingOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
topMostOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
topMostOverlayContent = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
|
@ -185,6 +185,12 @@ namespace osu.Game
|
|||||||
|
|
||||||
private RealmAccess realm;
|
private RealmAccess realm;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// For now, this is used as a source specifically for beat synced components.
|
||||||
|
/// Going forward, it could potentially be used as the single source-of-truth for beatmap timing.
|
||||||
|
/// </summary>
|
||||||
|
private readonly FramedBeatmapClock beatmapClock = new FramedBeatmapClock(true);
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
private Container content;
|
private Container content;
|
||||||
@ -273,7 +279,7 @@ namespace osu.Game
|
|||||||
dependencies.Cache(difficultyCache = new BeatmapDifficultyCache());
|
dependencies.Cache(difficultyCache = new BeatmapDifficultyCache());
|
||||||
|
|
||||||
// ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup()
|
// ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup()
|
||||||
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, realm, Scheduler, API, difficultyCache, LocalConfig));
|
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, realm, API, LocalConfig));
|
||||||
|
|
||||||
dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, realm, API, Audio, Resources, Host, defaultBeatmap, difficultyCache, performOnlineLookups: true));
|
dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, realm, API, Audio, Resources, Host, defaultBeatmap, difficultyCache, performOnlineLookups: true));
|
||||||
|
|
||||||
@ -368,10 +374,24 @@ namespace osu.Game
|
|||||||
AddInternal(MusicController = new MusicController());
|
AddInternal(MusicController = new MusicController());
|
||||||
dependencies.CacheAs(MusicController);
|
dependencies.CacheAs(MusicController);
|
||||||
|
|
||||||
|
MusicController.TrackChanged += onTrackChanged;
|
||||||
|
AddInternal(beatmapClock);
|
||||||
|
|
||||||
Ruleset.BindValueChanged(onRulesetChanged);
|
Ruleset.BindValueChanged(onRulesetChanged);
|
||||||
Beatmap.BindValueChanged(onBeatmapChanged);
|
Beatmap.BindValueChanged(onBeatmapChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onTrackChanged(WorkingBeatmap beatmap, TrackChangeDirection direction)
|
||||||
|
{
|
||||||
|
// FramedBeatmapClock uses a decoupled clock internally which will mutate the source if it is an `IAdjustableClock`.
|
||||||
|
// We don't want this for now, as the intention of beatmapClock is to be a read-only source for beat sync components.
|
||||||
|
//
|
||||||
|
// Encapsulating in a FramedClock will avoid any mutations.
|
||||||
|
var framedClock = new FramedClock(beatmap.Track);
|
||||||
|
|
||||||
|
beatmapClock.ChangeSource(framedClock);
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void InitialiseFonts()
|
protected virtual void InitialiseFonts()
|
||||||
{
|
{
|
||||||
AddFont(Resources, @"Fonts/osuFont");
|
AddFont(Resources, @"Fonts/osuFont");
|
||||||
@ -587,7 +607,7 @@ namespace osu.Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
ControlPointInfo IBeatSyncProvider.ControlPoints => Beatmap.Value.BeatmapLoaded ? Beatmap.Value.Beatmap.ControlPointInfo : null;
|
ControlPointInfo IBeatSyncProvider.ControlPoints => Beatmap.Value.BeatmapLoaded ? Beatmap.Value.Beatmap.ControlPointInfo : null;
|
||||||
IClock IBeatSyncProvider.Clock => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track : (IClock)null;
|
IClock IBeatSyncProvider.Clock => beatmapClock;
|
||||||
ChannelAmplitudes IHasAmplitudes.CurrentAmplitudes => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track.CurrentAmplitudes : ChannelAmplitudes.Empty;
|
ChannelAmplitudes IHasAmplitudes.CurrentAmplitudes => Beatmap.Value.TrackLoaded ? Beatmap.Value.Track.CurrentAmplitudes : ChannelAmplitudes.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,8 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -87,27 +85,19 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
MD5Hash = apiBeatmap.MD5Hash
|
MD5Hash = apiBeatmap.MD5Hash
|
||||||
};
|
};
|
||||||
|
|
||||||
scoreManager.OrderByTotalScoreAsync(value.Scores.Select(s => s.ToScoreInfo(rulesets, beatmapInfo)).ToArray(), loadCancellationSource.Token)
|
var scores = scoreManager.OrderByTotalScore(value.Scores.Select(s => s.ToScoreInfo(rulesets, beatmapInfo))).ToArray();
|
||||||
.ContinueWith(task => Schedule(() =>
|
var topScore = scores.First();
|
||||||
{
|
|
||||||
if (loadCancellationSource.IsCancellationRequested)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var scores = task.GetResultSafely();
|
scoreTable.DisplayScores(scores, apiBeatmap.Status.GrantsPerformancePoints());
|
||||||
|
scoreTable.Show();
|
||||||
|
|
||||||
var topScore = scores.First();
|
var userScore = value.UserScore;
|
||||||
|
var userScoreInfo = userScore?.Score.ToScoreInfo(rulesets, beatmapInfo);
|
||||||
|
|
||||||
scoreTable.DisplayScores(scores, apiBeatmap.Status.GrantsPerformancePoints());
|
topScoresContainer.Add(new DrawableTopScore(topScore));
|
||||||
scoreTable.Show();
|
|
||||||
|
|
||||||
var userScore = value.UserScore;
|
if (userScoreInfo != null && userScoreInfo.OnlineID != topScore.OnlineID)
|
||||||
var userScoreInfo = userScore?.Score.ToScoreInfo(rulesets, beatmapInfo);
|
topScoresContainer.Add(new DrawableTopScore(userScoreInfo, userScore.Position));
|
||||||
|
|
||||||
topScoresContainer.Add(new DrawableTopScore(topScore));
|
|
||||||
|
|
||||||
if (userScoreInfo != null && userScoreInfo.OnlineID != topScore.OnlineID)
|
|
||||||
topScoresContainer.Add(new DrawableTopScore(userScoreInfo, userScore.Position));
|
|
||||||
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics;
|
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
|
using osuTK;
|
||||||
using NotificationsStrings = osu.Game.Localisation.NotificationsStrings;
|
using NotificationsStrings = osu.Game.Localisation.NotificationsStrings;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
@ -35,10 +35,28 @@ namespace osu.Game.Overlays
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private AudioManager audio { get; set; } = null!;
|
private AudioManager audio { get; set; } = null!;
|
||||||
|
|
||||||
private readonly IBindable<Visibility> firstRunSetupVisibility = new Bindable<Visibility>();
|
[Cached]
|
||||||
|
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||||
|
|
||||||
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
|
||||||
|
{
|
||||||
|
if (State.Value == Visibility.Visible)
|
||||||
|
return base.ReceivePositionalInputAt(screenSpacePos);
|
||||||
|
|
||||||
|
if (toastTray.IsDisplayingToasts)
|
||||||
|
return toastTray.ReceivePositionalInputAt(screenSpacePos);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool PropagatePositionalInputSubTree => base.PropagatePositionalInputSubTree || toastTray.IsDisplayingToasts;
|
||||||
|
|
||||||
|
private NotificationOverlayToastTray toastTray = null!;
|
||||||
|
|
||||||
|
private Container mainContent = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(FirstRunSetupOverlay? firstRunSetup)
|
private void load()
|
||||||
{
|
{
|
||||||
X = WIDTH;
|
X = WIDTH;
|
||||||
Width = WIDTH;
|
Width = WIDTH;
|
||||||
@ -46,53 +64,57 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
toastTray = new NotificationOverlayToastTray
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
ForwardNotificationToPermanentStore = addPermanently,
|
||||||
Colour = OsuColour.Gray(0.05f),
|
Origin = Anchor.TopRight,
|
||||||
},
|
},
|
||||||
new OsuScrollContainer
|
mainContent = new Container
|
||||||
{
|
{
|
||||||
Masking = true,
|
AlwaysPresent = true,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
sections = new FillFlowContainer<NotificationSection>
|
new Box
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Vertical,
|
RelativeSizeAxes = Axes.Both,
|
||||||
AutoSizeAxes = Axes.Y,
|
Colour = colourProvider.Background4,
|
||||||
RelativeSizeAxes = Axes.X,
|
},
|
||||||
|
new OsuScrollContainer
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new NotificationSection(AccountsStrings.NotificationsTitle, "Clear All")
|
sections = new FillFlowContainer<NotificationSection>
|
||||||
{
|
{
|
||||||
AcceptTypes = new[] { typeof(SimpleNotification) }
|
Direction = FillDirection.Vertical,
|
||||||
},
|
AutoSizeAxes = Axes.Y,
|
||||||
new NotificationSection(@"Running Tasks", @"Cancel All")
|
RelativeSizeAxes = Axes.X,
|
||||||
{
|
Children = new[]
|
||||||
AcceptTypes = new[] { typeof(ProgressNotification) }
|
{
|
||||||
|
new NotificationSection(AccountsStrings.NotificationsTitle, new[] { typeof(SimpleNotification) }, "Clear All"),
|
||||||
|
new NotificationSection(@"Running Tasks", new[] { typeof(ProgressNotification) }, @"Cancel All"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (firstRunSetup != null)
|
|
||||||
firstRunSetupVisibility.BindTo(firstRunSetup.State);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledDelegate? notificationsEnabler;
|
private ScheduledDelegate? notificationsEnabler;
|
||||||
|
|
||||||
private void updateProcessingMode()
|
private void updateProcessingMode()
|
||||||
{
|
{
|
||||||
bool enabled = (OverlayActivationMode.Value == OverlayActivation.All && firstRunSetupVisibility.Value != Visibility.Visible) || State.Value == Visibility.Visible;
|
bool enabled = OverlayActivationMode.Value == OverlayActivation.All || State.Value == Visibility.Visible;
|
||||||
|
|
||||||
notificationsEnabler?.Cancel();
|
notificationsEnabler?.Cancel();
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
// we want a slight delay before toggling notifications on to avoid the user becoming overwhelmed.
|
// we want a slight delay before toggling notifications on to avoid the user becoming overwhelmed.
|
||||||
notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, State.Value == Visibility.Visible ? 0 : 1000);
|
notificationsEnabler = Scheduler.AddDelayed(() => processingPosts = true, State.Value == Visibility.Visible ? 0 : 100);
|
||||||
else
|
else
|
||||||
processingPosts = false;
|
processingPosts = false;
|
||||||
}
|
}
|
||||||
@ -102,12 +124,13 @@ namespace osu.Game.Overlays
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
State.BindValueChanged(_ => updateProcessingMode());
|
State.BindValueChanged(_ => updateProcessingMode());
|
||||||
firstRunSetupVisibility.BindValueChanged(_ => updateProcessingMode());
|
|
||||||
OverlayActivationMode.BindValueChanged(_ => updateProcessingMode(), true);
|
OverlayActivationMode.BindValueChanged(_ => updateProcessingMode(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBindable<int> UnreadCount => unreadCount;
|
public IBindable<int> UnreadCount => unreadCount;
|
||||||
|
|
||||||
|
public int ToastCount => toastTray.UnreadCount;
|
||||||
|
|
||||||
private readonly BindableInt unreadCount = new BindableInt();
|
private readonly BindableInt unreadCount = new BindableInt();
|
||||||
|
|
||||||
private int runningDepth;
|
private int runningDepth;
|
||||||
@ -131,18 +154,28 @@ namespace osu.Game.Overlays
|
|||||||
if (notification is IHasCompletionTarget hasCompletionTarget)
|
if (notification is IHasCompletionTarget hasCompletionTarget)
|
||||||
hasCompletionTarget.CompletionTarget = Post;
|
hasCompletionTarget.CompletionTarget = Post;
|
||||||
|
|
||||||
var ourType = notification.GetType();
|
playDebouncedSample(notification.PopInSampleName);
|
||||||
|
|
||||||
var section = sections.Children.FirstOrDefault(s => s.AcceptTypes.Any(accept => accept.IsAssignableFrom(ourType)));
|
if (State.Value == Visibility.Hidden)
|
||||||
section?.Add(notification, notification.DisplayOnTop ? -runningDepth : runningDepth);
|
toastTray.Post(notification);
|
||||||
|
else
|
||||||
if (notification.IsImportant)
|
addPermanently(notification);
|
||||||
Show();
|
|
||||||
|
|
||||||
updateCounts();
|
updateCounts();
|
||||||
playDebouncedSample(notification.PopInSampleName);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private void addPermanently(Notification notification)
|
||||||
|
{
|
||||||
|
var ourType = notification.GetType();
|
||||||
|
int depth = notification.DisplayOnTop ? -runningDepth : runningDepth;
|
||||||
|
|
||||||
|
var section = sections.Children.First(s => s.AcceptedNotificationTypes.Any(accept => accept.IsAssignableFrom(ourType)));
|
||||||
|
|
||||||
|
section.Add(notification, depth);
|
||||||
|
|
||||||
|
updateCounts();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -156,7 +189,9 @@ namespace osu.Game.Overlays
|
|||||||
base.PopIn();
|
base.PopIn();
|
||||||
|
|
||||||
this.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
|
this.MoveToX(0, TRANSITION_LENGTH, Easing.OutQuint);
|
||||||
this.FadeTo(1, TRANSITION_LENGTH, Easing.OutQuint);
|
mainContent.FadeTo(1, TRANSITION_LENGTH, Easing.OutQuint);
|
||||||
|
|
||||||
|
toastTray.FlushAllToasts();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void PopOut()
|
protected override void PopOut()
|
||||||
@ -166,7 +201,7 @@ namespace osu.Game.Overlays
|
|||||||
markAllRead();
|
markAllRead();
|
||||||
|
|
||||||
this.MoveToX(WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
|
this.MoveToX(WIDTH, TRANSITION_LENGTH, Easing.OutQuint);
|
||||||
this.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
|
mainContent.FadeTo(0, TRANSITION_LENGTH, Easing.OutQuint);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notificationClosed()
|
private void notificationClosed()
|
||||||
@ -187,16 +222,16 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCounts()
|
|
||||||
{
|
|
||||||
unreadCount.Value = sections.Select(c => c.UnreadCount).Sum();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void markAllRead()
|
private void markAllRead()
|
||||||
{
|
{
|
||||||
sections.Children.ForEach(s => s.MarkAllRead());
|
sections.Children.ForEach(s => s.MarkAllRead());
|
||||||
|
toastTray.MarkAllRead();
|
||||||
updateCounts();
|
updateCounts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateCounts()
|
||||||
|
{
|
||||||
|
unreadCount.Value = sections.Select(c => c.UnreadCount).Sum() + toastTray.UnreadCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
153
osu.Game/Overlays/NotificationOverlayToastTray.cs
Normal file
153
osu.Game/Overlays/NotificationOverlayToastTray.cs
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
// 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.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Colour;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Effects;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Overlays.Notifications;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A tray which attaches to the left of <see cref="NotificationOverlay"/> to show temporary toasts.
|
||||||
|
/// </summary>
|
||||||
|
public class NotificationOverlayToastTray : CompositeDrawable
|
||||||
|
{
|
||||||
|
public bool IsDisplayingToasts => toastFlow.Count > 0;
|
||||||
|
|
||||||
|
private FillFlowContainer<Notification> toastFlow = null!;
|
||||||
|
private BufferedContainer toastContentBackground = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
|
public Action<Notification>? ForwardNotificationToPermanentStore { get; set; }
|
||||||
|
|
||||||
|
public int UnreadCount => toastFlow.Count(n => !n.WasClosed && !n.Read)
|
||||||
|
+ InternalChildren.OfType<Notification>().Count(n => !n.WasClosed && !n.Read);
|
||||||
|
|
||||||
|
private int runningDepth;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
AutoSizeAxes = Axes.Y;
|
||||||
|
Padding = new MarginPadding(20);
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
toastContentBackground = (new Box
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
Colour = ColourInfo.GradientVertical(
|
||||||
|
colourProvider.Background6.Opacity(0.7f),
|
||||||
|
colourProvider.Background6.Opacity(0.5f)),
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
}.WithEffect(new BlurEffect
|
||||||
|
{
|
||||||
|
PadExtent = true,
|
||||||
|
Sigma = new Vector2(20),
|
||||||
|
}).With(postEffectDrawable =>
|
||||||
|
{
|
||||||
|
postEffectDrawable.Scale = new Vector2(1.5f, 1);
|
||||||
|
postEffectDrawable.Position += new Vector2(70, -50);
|
||||||
|
postEffectDrawable.AutoSizeAxes = Axes.None;
|
||||||
|
postEffectDrawable.RelativeSizeAxes = Axes.X;
|
||||||
|
})),
|
||||||
|
toastFlow = new AlwaysUpdateFillFlowContainer<Notification>
|
||||||
|
{
|
||||||
|
LayoutDuration = 150,
|
||||||
|
LayoutEasing = Easing.OutQuart,
|
||||||
|
Spacing = new Vector2(3),
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MarkAllRead()
|
||||||
|
{
|
||||||
|
toastFlow.Children.ForEach(n => n.Read = true);
|
||||||
|
InternalChildren.OfType<Notification>().ForEach(n => n.Read = true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void FlushAllToasts()
|
||||||
|
{
|
||||||
|
foreach (var notification in toastFlow.ToArray())
|
||||||
|
forwardNotification(notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Post(Notification notification)
|
||||||
|
{
|
||||||
|
++runningDepth;
|
||||||
|
|
||||||
|
int depth = notification.DisplayOnTop ? -runningDepth : runningDepth;
|
||||||
|
|
||||||
|
toastFlow.Insert(depth, notification);
|
||||||
|
|
||||||
|
scheduleDismissal();
|
||||||
|
|
||||||
|
void scheduleDismissal() => Scheduler.AddDelayed(() =>
|
||||||
|
{
|
||||||
|
// Notification dismissed by user.
|
||||||
|
if (notification.WasClosed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Notification forwarded away.
|
||||||
|
if (notification.Parent != toastFlow)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Notification hovered; delay dismissal.
|
||||||
|
if (notification.IsHovered)
|
||||||
|
{
|
||||||
|
scheduleDismissal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// All looks good, forward away!
|
||||||
|
forwardNotification(notification);
|
||||||
|
}, notification.IsImportant ? 12000 : 2500);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void forwardNotification(Notification notification)
|
||||||
|
{
|
||||||
|
Debug.Assert(notification.Parent == toastFlow);
|
||||||
|
|
||||||
|
// Temporarily remove from flow so we can animate the position off to the right.
|
||||||
|
toastFlow.Remove(notification);
|
||||||
|
AddInternal(notification);
|
||||||
|
|
||||||
|
notification.MoveToOffset(new Vector2(400, 0), NotificationOverlay.TRANSITION_LENGTH, Easing.OutQuint);
|
||||||
|
notification.FadeOut(NotificationOverlay.TRANSITION_LENGTH, Easing.OutQuint).OnComplete(_ =>
|
||||||
|
{
|
||||||
|
RemoveInternal(notification);
|
||||||
|
ForwardNotificationToPermanentStore?.Invoke(notification);
|
||||||
|
|
||||||
|
notification.FadeIn(300, Easing.OutQuint);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
float height = toastFlow.DrawHeight + 120;
|
||||||
|
float alpha = IsDisplayingToasts ? MathHelper.Clamp(toastFlow.DrawHeight / 40, 0, 1) * toastFlow.Children.Max(n => n.Alpha) : 0;
|
||||||
|
|
||||||
|
toastContentBackground.Height = (float)Interpolation.DampContinuously(toastContentBackground.Height, height, 10, Clock.ElapsedFrameTime);
|
||||||
|
toastContentBackground.Alpha = (float)Interpolation.DampContinuously(toastContentBackground.Alpha, alpha, 10, Clock.ElapsedFrameTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -26,7 +24,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// User requested close.
|
/// User requested close.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action Closed;
|
public event Action? Closed;
|
||||||
|
|
||||||
public abstract LocalisableString Text { get; set; }
|
public abstract LocalisableString Text { get; set; }
|
||||||
|
|
||||||
@ -38,7 +36,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Run on user activating the notification. Return true to close.
|
/// Run on user activating the notification. Return true to close.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<bool> Activated;
|
public Func<bool>? Activated;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should we show at the top of our section on display?
|
/// Should we show at the top of our section on display?
|
||||||
@ -48,22 +46,32 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
public virtual string PopInSampleName => "UI/notification-pop-in";
|
public virtual string PopInSampleName => "UI/notification-pop-in";
|
||||||
|
|
||||||
protected NotificationLight Light;
|
protected NotificationLight Light;
|
||||||
private readonly CloseButton closeButton;
|
|
||||||
protected Container IconContent;
|
protected Container IconContent;
|
||||||
|
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
protected Container NotificationContent;
|
protected Container MainContent;
|
||||||
|
|
||||||
public virtual bool Read { get; set; }
|
public virtual bool Read { get; set; }
|
||||||
|
|
||||||
|
protected virtual IconUsage CloseButtonIcon => FontAwesome.Solid.Check;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
|
private readonly Box initialFlash;
|
||||||
|
|
||||||
|
private Box background = null!;
|
||||||
|
|
||||||
protected Notification()
|
protected Notification()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
Light = new NotificationLight
|
Light = new NotificationLight
|
||||||
{
|
{
|
||||||
@ -71,9 +79,9 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
},
|
},
|
||||||
NotificationContent = new Container
|
MainContent = new Container
|
||||||
{
|
{
|
||||||
CornerRadius = 8,
|
CornerRadius = 6,
|
||||||
Masking = true,
|
Masking = true,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
@ -81,61 +89,84 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
AutoSizeEasing = Easing.OutQuint,
|
AutoSizeEasing = Easing.OutQuint,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new GridContainer
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.White,
|
|
||||||
},
|
|
||||||
new Container
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Padding = new MarginPadding(5),
|
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Children = new Drawable[]
|
RowDimensions = new[]
|
||||||
{
|
{
|
||||||
IconContent = new Container
|
new Dimension(GridSizeMode.AutoSize, minSize: 60)
|
||||||
{
|
|
||||||
Size = new Vector2(40),
|
|
||||||
Masking = true,
|
|
||||||
CornerRadius = 5,
|
|
||||||
},
|
|
||||||
content = new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Padding = new MarginPadding
|
|
||||||
{
|
|
||||||
Left = 45,
|
|
||||||
Right = 30
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
closeButton = new CloseButton
|
|
||||||
{
|
|
||||||
Alpha = 0,
|
|
||||||
Action = Close,
|
|
||||||
Anchor = Anchor.CentreRight,
|
|
||||||
Origin = Anchor.CentreRight,
|
|
||||||
Margin = new MarginPadding
|
|
||||||
{
|
|
||||||
Right = 5
|
|
||||||
},
|
},
|
||||||
}
|
ColumnDimensions = new[]
|
||||||
|
{
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
new Dimension(),
|
||||||
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
|
},
|
||||||
|
Content = new[]
|
||||||
|
{
|
||||||
|
new Drawable[]
|
||||||
|
{
|
||||||
|
IconContent = new Container
|
||||||
|
{
|
||||||
|
Width = 40,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Padding = new MarginPadding(10),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
content = new Container
|
||||||
|
{
|
||||||
|
Masking = true,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new CloseButton(CloseButtonIcon)
|
||||||
|
{
|
||||||
|
Action = Close,
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
initialFlash = new Box
|
||||||
|
{
|
||||||
|
Colour = Color4.White.Opacity(0.8f),
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
MainContent.Add(background = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = colourProvider.Background3,
|
||||||
|
Depth = float.MaxValue
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
closeButton.FadeIn(75);
|
background.FadeColour(colourProvider.Background2, 200, Easing.OutQuint);
|
||||||
return base.OnHover(e);
|
return base.OnHover(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
closeButton.FadeOut(75);
|
background.FadeColour(colourProvider.Background3, 200, Easing.OutQuint);
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +183,11 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
this.FadeInFromZero(200);
|
this.FadeInFromZero(200);
|
||||||
NotificationContent.MoveToX(DrawSize.X);
|
|
||||||
NotificationContent.MoveToX(0, 500, Easing.OutQuint);
|
MainContent.MoveToX(DrawSize.X);
|
||||||
|
MainContent.MoveToX(0, 500, Easing.OutQuint);
|
||||||
|
|
||||||
|
initialFlash.FadeOutFromOne(2000, Easing.OutQuart);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool WasClosed;
|
public bool WasClosed;
|
||||||
@ -171,40 +205,55 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
private class CloseButton : OsuClickableContainer
|
private class CloseButton : OsuClickableContainer
|
||||||
{
|
{
|
||||||
private Color4 hoverColour;
|
private SpriteIcon icon = null!;
|
||||||
|
private Box background = null!;
|
||||||
|
|
||||||
public CloseButton()
|
private readonly IconUsage iconUsage;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
|
public CloseButton(IconUsage iconUsage)
|
||||||
{
|
{
|
||||||
Colour = OsuColour.Gray(0.2f);
|
this.iconUsage = iconUsage;
|
||||||
AutoSizeAxes = Axes.Both;
|
}
|
||||||
|
|
||||||
Children = new[]
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
Width = 28;
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SpriteIcon
|
background = new Box
|
||||||
|
{
|
||||||
|
Colour = OsuColour.Gray(0).Opacity(0.15f),
|
||||||
|
Alpha = 0,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
icon = new SpriteIcon
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Icon = FontAwesome.Solid.TimesCircle,
|
Icon = iconUsage,
|
||||||
Size = new Vector2(20),
|
Size = new Vector2(12),
|
||||||
|
Colour = colourProvider.Foreground1,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours)
|
|
||||||
{
|
|
||||||
hoverColour = colours.Yellow;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
this.FadeColour(hoverColour, 200);
|
background.FadeIn(200, Easing.OutQuint);
|
||||||
|
icon.FadeColour(colourProvider.Content1, 200, Easing.OutQuint);
|
||||||
return base.OnHover(e);
|
return base.OnHover(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
protected override void OnHoverLost(HoverLostEvent e)
|
||||||
{
|
{
|
||||||
this.FadeColour(OsuColour.Gray(0.2f), 200);
|
background.FadeOut(200, Easing.OutQuint);
|
||||||
|
icon.FadeColour(colourProvider.Foreground1, 200, Easing.OutQuint);
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,7 +261,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
public class NotificationLight : Container
|
public class NotificationLight : Container
|
||||||
{
|
{
|
||||||
private bool pulsate;
|
private bool pulsate;
|
||||||
private Container pulsateLayer;
|
private Container pulsateLayer = null!;
|
||||||
|
|
||||||
public bool Pulsate
|
public bool Pulsate
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -21,9 +19,9 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
{
|
{
|
||||||
public class NotificationSection : AlwaysUpdateFillFlowContainer<Drawable>
|
public class NotificationSection : AlwaysUpdateFillFlowContainer<Drawable>
|
||||||
{
|
{
|
||||||
private OsuSpriteText countDrawable;
|
private OsuSpriteText countDrawable = null!;
|
||||||
|
|
||||||
private FlowContainer<Notification> notifications;
|
private FlowContainer<Notification> notifications = null!;
|
||||||
|
|
||||||
public int DisplayedCount => notifications.Count(n => !n.WasClosed);
|
public int DisplayedCount => notifications.Count(n => !n.WasClosed);
|
||||||
public int UnreadCount => notifications.Count(n => !n.WasClosed && !n.Read);
|
public int UnreadCount => notifications.Count(n => !n.WasClosed && !n.Read);
|
||||||
@ -33,14 +31,16 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
notifications.Insert((int)position, notification);
|
notifications.Insert((int)position, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Type> AcceptTypes;
|
public IEnumerable<Type> AcceptedNotificationTypes { get; }
|
||||||
|
|
||||||
private readonly string clearButtonText;
|
private readonly string clearButtonText;
|
||||||
|
|
||||||
private readonly LocalisableString titleText;
|
private readonly LocalisableString titleText;
|
||||||
|
|
||||||
public NotificationSection(LocalisableString title, string clearButtonText)
|
public NotificationSection(LocalisableString title, IEnumerable<Type> acceptedNotificationTypes, string clearButtonText)
|
||||||
{
|
{
|
||||||
|
AcceptedNotificationTypes = acceptedNotificationTypes.ToArray();
|
||||||
|
|
||||||
this.clearButtonText = clearButtonText.ToUpperInvariant();
|
this.clearButtonText = clearButtonText.ToUpperInvariant();
|
||||||
titleText = title;
|
titleText = title;
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
public void MarkAllRead()
|
public void MarkAllRead()
|
||||||
{
|
{
|
||||||
notifications?.Children.ForEach(n => n.Read = true);
|
notifications.Children.ForEach(n => n.Read = true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
IconBackground.Colour = ColourInfo.GradientVertical(colours.GreenDark, colours.GreenLight);
|
IconContent.Colour = ColourInfo.GradientVertical(colours.GreenDark, colours.GreenLight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -25,6 +23,18 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
{
|
{
|
||||||
private const float loading_spinner_size = 22;
|
private const float loading_spinner_size = 22;
|
||||||
|
|
||||||
|
public Func<bool>? CancelRequested { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The function to post completion notifications back to.
|
||||||
|
/// </summary>
|
||||||
|
public Action<Notification>? CompletionTarget { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An action to complete when the completion notification is clicked. Return true to close.
|
||||||
|
/// </summary>
|
||||||
|
public Func<bool>? CompletionClickAction { get; set; }
|
||||||
|
|
||||||
private LocalisableString text;
|
private LocalisableString text;
|
||||||
|
|
||||||
public override LocalisableString Text
|
public override LocalisableString Text
|
||||||
@ -47,11 +57,14 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
progress = value;
|
progress = value;
|
||||||
Scheduler.AddOnce(updateProgress, progress);
|
Scheduler.AddOnce(p => progressBar.Progress = p, progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProgress(float progress) => progressBar.Progress = progress;
|
protected override IconUsage CloseButtonIcon => FontAwesome.Solid.Times;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OverlayColourProvider colourProvider { get; set; } = null!;
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
@ -90,7 +103,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
Light.Pulsate = false;
|
Light.Pulsate = false;
|
||||||
progressBar.Active = false;
|
progressBar.Active = false;
|
||||||
|
|
||||||
iconBackground.FadeColour(ColourInfo.GradientVertical(colourQueued, colourQueued.Lighten(0.5f)), colour_fade_duration);
|
IconContent.FadeColour(ColourInfo.GradientVertical(colourQueued, colourQueued.Lighten(0.5f)), colour_fade_duration);
|
||||||
loadingSpinner.Show();
|
loadingSpinner.Show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -99,14 +112,14 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
Light.Pulsate = true;
|
Light.Pulsate = true;
|
||||||
progressBar.Active = true;
|
progressBar.Active = true;
|
||||||
|
|
||||||
iconBackground.FadeColour(ColourInfo.GradientVertical(colourActive, colourActive.Lighten(0.5f)), colour_fade_duration);
|
IconContent.FadeColour(ColourInfo.GradientVertical(colourActive, colourActive.Lighten(0.5f)), colour_fade_duration);
|
||||||
loadingSpinner.Show();
|
loadingSpinner.Show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ProgressNotificationState.Cancelled:
|
case ProgressNotificationState.Cancelled:
|
||||||
cancellationTokenSource.Cancel();
|
cancellationTokenSource.Cancel();
|
||||||
|
|
||||||
iconBackground.FadeColour(ColourInfo.GradientVertical(Color4.Gray, Color4.Gray.Lighten(0.5f)), colour_fade_duration);
|
IconContent.FadeColour(ColourInfo.GradientVertical(Color4.Gray, Color4.Gray.Lighten(0.5f)), colour_fade_duration);
|
||||||
loadingSpinner.Hide();
|
loadingSpinner.Hide();
|
||||||
|
|
||||||
var icon = new SpriteIcon
|
var icon = new SpriteIcon
|
||||||
@ -128,8 +141,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
case ProgressNotificationState.Completed:
|
case ProgressNotificationState.Completed:
|
||||||
loadingSpinner.Hide();
|
loadingSpinner.Hide();
|
||||||
NotificationContent.MoveToY(-DrawSize.Y / 2, 200, Easing.OutQuint);
|
Completed();
|
||||||
this.FadeOut(200).Finally(_ => Completed());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,7 +154,7 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
Text = CompletionText
|
Text = CompletionText
|
||||||
};
|
};
|
||||||
|
|
||||||
protected virtual void Completed()
|
protected void Completed()
|
||||||
{
|
{
|
||||||
CompletionTarget?.Invoke(CreateCompletionNotification());
|
CompletionTarget?.Invoke(CreateCompletionNotification());
|
||||||
base.Close();
|
base.Close();
|
||||||
@ -155,21 +167,19 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
private Color4 colourActive;
|
private Color4 colourActive;
|
||||||
private Color4 colourCancelled;
|
private Color4 colourCancelled;
|
||||||
|
|
||||||
private Box iconBackground;
|
private LoadingSpinner loadingSpinner = null!;
|
||||||
private LoadingSpinner loadingSpinner;
|
|
||||||
|
|
||||||
private readonly TextFlowContainer textDrawable;
|
private readonly TextFlowContainer textDrawable;
|
||||||
|
|
||||||
public ProgressNotification()
|
public ProgressNotification()
|
||||||
{
|
{
|
||||||
Content.Add(textDrawable = new OsuTextFlowContainer
|
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14, weight: FontWeight.Medium))
|
||||||
{
|
{
|
||||||
Colour = OsuColour.Gray(128),
|
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
});
|
});
|
||||||
|
|
||||||
NotificationContent.Add(progressBar = new ProgressBar
|
MainContent.Add(progressBar = new ProgressBar
|
||||||
{
|
{
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
@ -194,10 +204,10 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
|
|
||||||
IconContent.AddRange(new Drawable[]
|
IconContent.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
iconBackground = new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = Color4.White,
|
Colour = colourProvider.Background5,
|
||||||
},
|
},
|
||||||
loadingSpinner = new LoadingSpinner
|
loadingSpinner = new LoadingSpinner
|
||||||
{
|
{
|
||||||
@ -222,18 +232,6 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Func<bool> CancelRequested { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The function to post completion notifications back to.
|
|
||||||
/// </summary>
|
|
||||||
public Action<Notification> CompletionTarget { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// An action to complete when the completion notification is clicked. Return true to close.
|
|
||||||
/// </summary>
|
|
||||||
public Func<bool> CompletionClickAction;
|
|
||||||
|
|
||||||
private class ProgressBar : Container
|
private class ProgressBar : Container
|
||||||
{
|
{
|
||||||
private readonly Box box;
|
private readonly Box box;
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
@ -26,7 +23,8 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
text = value;
|
text = value;
|
||||||
textDrawable.Text = text;
|
if (textDrawable != null)
|
||||||
|
textDrawable.Text = text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,48 +36,44 @@ namespace osu.Game.Overlays.Notifications
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
icon = value;
|
icon = value;
|
||||||
iconDrawable.Icon = icon;
|
if (iconDrawable != null)
|
||||||
|
iconDrawable.Icon = icon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly TextFlowContainer textDrawable;
|
private TextFlowContainer? textDrawable;
|
||||||
private readonly SpriteIcon iconDrawable;
|
|
||||||
|
|
||||||
protected Box IconBackground;
|
private SpriteIcon? iconDrawable;
|
||||||
|
|
||||||
public SimpleNotification()
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours, OverlayColourProvider colourProvider)
|
||||||
{
|
{
|
||||||
|
Light.Colour = colours.Green;
|
||||||
|
|
||||||
IconContent.AddRange(new Drawable[]
|
IconContent.AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
IconBackground = new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = ColourInfo.GradientVertical(OsuColour.Gray(0.2f), OsuColour.Gray(0.6f))
|
Colour = colourProvider.Background5,
|
||||||
},
|
},
|
||||||
iconDrawable = new SpriteIcon
|
iconDrawable = new SpriteIcon
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
Icon = icon,
|
Icon = icon,
|
||||||
Size = new Vector2(20),
|
Size = new Vector2(16),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14))
|
Content.Add(textDrawable = new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 14, weight: FontWeight.Medium))
|
||||||
{
|
{
|
||||||
Colour = OsuColour.Gray(128),
|
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Text = text
|
Text = text
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuColour colours)
|
|
||||||
{
|
|
||||||
Light.Colour = colours.Green;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Read
|
public override bool Read
|
||||||
{
|
{
|
||||||
get => base.Read;
|
get => base.Read;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using System.Diagnostics;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -37,6 +38,10 @@ namespace osu.Game.Overlays.Profile
|
|||||||
// todo: pending implementation.
|
// todo: pending implementation.
|
||||||
// TabControl.AddItem(LayoutStrings.HeaderUsersModding);
|
// TabControl.AddItem(LayoutStrings.HeaderUsersModding);
|
||||||
|
|
||||||
|
// Haphazardly guaranteed by OverlayHeader constructor (see CreateBackground / CreateContent).
|
||||||
|
Debug.Assert(centreHeaderContainer != null);
|
||||||
|
Debug.Assert(detailHeaderContainer != null);
|
||||||
|
|
||||||
centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true);
|
centreHeaderContainer.DetailsVisible.BindValueChanged(visible => detailHeaderContainer.Expanded = visible.NewValue, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,9 +77,16 @@ namespace osu.Game.Rulesets
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var instanceInfo = (Activator.CreateInstance(resolvedType) as Ruleset)?.RulesetInfo
|
var instance = (Activator.CreateInstance(resolvedType) as Ruleset);
|
||||||
|
var instanceInfo = instance?.RulesetInfo
|
||||||
?? throw new RulesetLoadException(@"Instantiation failure");
|
?? throw new RulesetLoadException(@"Instantiation failure");
|
||||||
|
|
||||||
|
if (!checkRulesetUpToDate(instance))
|
||||||
|
{
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(instance.RulesetAPIVersionSupported),
|
||||||
|
$"Ruleset API version is too old (was {instance.RulesetAPIVersionSupported}, expected {Ruleset.CURRENT_RULESET_API_VERSION})");
|
||||||
|
}
|
||||||
|
|
||||||
// If a ruleset isn't up-to-date with the API, it could cause a crash at an arbitrary point of execution.
|
// If a ruleset isn't up-to-date with the API, it could cause a crash at an arbitrary point of execution.
|
||||||
// To eagerly handle cases of missing implementations, enumerate all types here and mark as non-available on throw.
|
// To eagerly handle cases of missing implementations, enumerate all types here and mark as non-available on throw.
|
||||||
resolvedType.Assembly.GetTypes();
|
resolvedType.Assembly.GetTypes();
|
||||||
@ -104,6 +111,23 @@ namespace osu.Game.Rulesets
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool checkRulesetUpToDate(Ruleset instance)
|
||||||
|
{
|
||||||
|
switch (instance.RulesetAPIVersionSupported)
|
||||||
|
{
|
||||||
|
// The default `virtual` implementation leaves the version string empty.
|
||||||
|
// Consider rulesets which haven't override the version as up-to-date for now.
|
||||||
|
// At some point (once ruleset devs add versioning), we'll probably want to disallow this for deployed builds.
|
||||||
|
case @"":
|
||||||
|
// Ruleset is up-to-date, all good.
|
||||||
|
case Ruleset.CURRENT_RULESET_API_VERSION:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void testRulesetCompatibility(RulesetInfo rulesetInfo)
|
private void testRulesetCompatibility(RulesetInfo rulesetInfo)
|
||||||
{
|
{
|
||||||
// do various operations to ensure that we are in a good state.
|
// do various operations to ensure that we are in a good state.
|
||||||
|
@ -7,33 +7,33 @@ using System;
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
|
using osu.Framework.Extensions.EnumExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using osu.Game.Beatmaps;
|
|
||||||
using osu.Game.Overlays.Settings;
|
|
||||||
using osu.Game.Rulesets.Edit;
|
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Rulesets.Replays.Types;
|
|
||||||
using osu.Game.Rulesets.UI;
|
|
||||||
using osu.Game.Beatmaps.Legacy;
|
|
||||||
using osu.Game.Configuration;
|
|
||||||
using osu.Game.Rulesets.Configuration;
|
|
||||||
using osu.Game.Rulesets.Difficulty;
|
|
||||||
using osu.Game.Rulesets.Scoring;
|
|
||||||
using osu.Game.Scoring;
|
|
||||||
using osu.Game.Skinning;
|
|
||||||
using osu.Game.Users;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Framework.Extensions.EnumExtensions;
|
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.Legacy;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
|
using osu.Game.Overlays.Settings;
|
||||||
|
using osu.Game.Rulesets.Configuration;
|
||||||
|
using osu.Game.Rulesets.Difficulty;
|
||||||
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Rulesets.Filter;
|
using osu.Game.Rulesets.Filter;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Replays.Types;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Screens.Edit.Setup;
|
using osu.Game.Screens.Edit.Setup;
|
||||||
using osu.Game.Screens.Ranking.Statistics;
|
using osu.Game.Screens.Ranking.Statistics;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets
|
namespace osu.Game.Rulesets
|
||||||
{
|
{
|
||||||
@ -44,6 +44,24 @@ namespace osu.Game.Rulesets
|
|||||||
|
|
||||||
private static readonly ConcurrentDictionary<string, IMod[]> mod_reference_cache = new ConcurrentDictionary<string, IMod[]>();
|
private static readonly ConcurrentDictionary<string, IMod[]> mod_reference_cache = new ConcurrentDictionary<string, IMod[]>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Version history:
|
||||||
|
/// 2022.205.0 FramedReplayInputHandler.CollectPendingInputs renamed to FramedReplayHandler.CollectReplayInputs.
|
||||||
|
/// 2022.822.0 All strings return values have been converted to LocalisableString to allow for localisation support.
|
||||||
|
/// </summary>
|
||||||
|
public const string CURRENT_RULESET_API_VERSION = "2022.822.0";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Define the ruleset API version supported by this ruleset.
|
||||||
|
/// Ruleset implementations should be updated to support the latest version to ensure they can still be loaded.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Generally, all ruleset implementations should point this directly to <see cref="CURRENT_RULESET_API_VERSION"/>.
|
||||||
|
/// This will ensure that each time you compile a new release, it will pull in the most recent version.
|
||||||
|
/// See https://github.com/ppy/osu/wiki/Breaking-Changes for full details on required ongoing changes.
|
||||||
|
/// </remarks>
|
||||||
|
public virtual string RulesetAPIVersionSupported => string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A queryable source containing all available mods.
|
/// A queryable source containing all available mods.
|
||||||
/// Call <see cref="IMod.CreateInstance"/> for consumption purposes.
|
/// Call <see cref="IMod.CreateInstance"/> for consumption purposes.
|
||||||
|
@ -404,7 +404,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Populates the given score with remaining statistics as "missed" and marks it with <see cref="ScoreRank.F"/> rank.
|
/// Populates a failed score, marking it with the <see cref="ScoreRank.F"/> rank.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void FailScore(ScoreInfo score)
|
public void FailScore(ScoreInfo score)
|
||||||
{
|
{
|
||||||
@ -414,22 +414,6 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
score.Passed = false;
|
score.Passed = false;
|
||||||
Rank.Value = ScoreRank.F;
|
Rank.Value = ScoreRank.F;
|
||||||
|
|
||||||
Debug.Assert(maximumResultCounts != null);
|
|
||||||
|
|
||||||
if (maximumResultCounts.TryGetValue(HitResult.LargeTickHit, out int maximumLargeTick))
|
|
||||||
scoreResultCounts[HitResult.LargeTickMiss] = maximumLargeTick - scoreResultCounts.GetValueOrDefault(HitResult.LargeTickHit);
|
|
||||||
|
|
||||||
if (maximumResultCounts.TryGetValue(HitResult.SmallTickHit, out int maximumSmallTick))
|
|
||||||
scoreResultCounts[HitResult.SmallTickMiss] = maximumSmallTick - scoreResultCounts.GetValueOrDefault(HitResult.SmallTickHit);
|
|
||||||
|
|
||||||
int maximumBonusOrIgnore = maximumResultCounts.Where(kvp => kvp.Key.IsBonus() || kvp.Key == HitResult.IgnoreHit).Sum(kvp => kvp.Value);
|
|
||||||
int currentBonusOrIgnore = scoreResultCounts.Where(kvp => kvp.Key.IsBonus() || kvp.Key == HitResult.IgnoreHit).Sum(kvp => kvp.Value);
|
|
||||||
scoreResultCounts[HitResult.IgnoreMiss] = maximumBonusOrIgnore - currentBonusOrIgnore;
|
|
||||||
|
|
||||||
int maximumBasic = maximumResultCounts.SingleOrDefault(kvp => kvp.Key.IsBasic()).Value;
|
|
||||||
int currentBasic = scoreResultCounts.Where(kvp => kvp.Key.IsBasic() && kvp.Key != HitResult.Miss).Sum(kvp => kvp.Value);
|
|
||||||
scoreResultCounts[HitResult.Miss] = maximumBasic - currentBasic;
|
|
||||||
|
|
||||||
PopulateScore(score);
|
PopulateScore(score);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,12 @@ namespace osu.Game.Scoring
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
using (var stream = store.GetStream(replayFilename))
|
using (var stream = store.GetStream(replayFilename))
|
||||||
|
{
|
||||||
|
if (stream == null)
|
||||||
|
return;
|
||||||
|
|
||||||
Replay = new DatabasedLegacyScoreDecoder(rulesets, beatmaps).Parse(stream).Replay;
|
Replay = new DatabasedLegacyScoreDecoder(rulesets, beatmaps).Parse(stream).Replay;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions;
|
|
||||||
using osu.Framework.Logging;
|
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Threading;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
@ -28,17 +25,12 @@ namespace osu.Game.Scoring
|
|||||||
{
|
{
|
||||||
public class ScoreManager : ModelManager<ScoreInfo>, IModelImporter<ScoreInfo>
|
public class ScoreManager : ModelManager<ScoreInfo>, IModelImporter<ScoreInfo>
|
||||||
{
|
{
|
||||||
private readonly Scheduler scheduler;
|
|
||||||
private readonly BeatmapDifficultyCache difficultyCache;
|
|
||||||
private readonly OsuConfigManager configManager;
|
private readonly OsuConfigManager configManager;
|
||||||
private readonly ScoreImporter scoreImporter;
|
private readonly ScoreImporter scoreImporter;
|
||||||
|
|
||||||
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, Scheduler scheduler, IAPIProvider api,
|
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, IAPIProvider api, OsuConfigManager configManager = null)
|
||||||
BeatmapDifficultyCache difficultyCache = null, OsuConfigManager configManager = null)
|
|
||||||
: base(storage, realm)
|
: base(storage, realm)
|
||||||
{
|
{
|
||||||
this.scheduler = scheduler;
|
|
||||||
this.difficultyCache = difficultyCache;
|
|
||||||
this.configManager = configManager;
|
this.configManager = configManager;
|
||||||
|
|
||||||
scoreImporter = new ScoreImporter(rulesets, beatmaps, storage, realm, api)
|
scoreImporter = new ScoreImporter(rulesets, beatmaps, storage, realm, api)
|
||||||
@ -63,28 +55,9 @@ namespace osu.Game.Scoring
|
|||||||
/// Orders an array of <see cref="ScoreInfo"/>s by total score.
|
/// Orders an array of <see cref="ScoreInfo"/>s by total score.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="scores">The array of <see cref="ScoreInfo"/>s to reorder.</param>
|
/// <param name="scores">The array of <see cref="ScoreInfo"/>s to reorder.</param>
|
||||||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the process.</param>
|
|
||||||
/// <returns>The given <paramref name="scores"/> ordered by decreasing total score.</returns>
|
/// <returns>The given <paramref name="scores"/> ordered by decreasing total score.</returns>
|
||||||
public async Task<ScoreInfo[]> OrderByTotalScoreAsync(ScoreInfo[] scores, CancellationToken cancellationToken = default)
|
public IEnumerable<ScoreInfo> OrderByTotalScore(IEnumerable<ScoreInfo> scores)
|
||||||
{
|
=> scores.OrderByDescending(s => GetTotalScore(s)).ThenBy(s => s.OnlineID);
|
||||||
if (difficultyCache != null)
|
|
||||||
{
|
|
||||||
// Compute difficulties asynchronously first to prevent blocking via the GetTotalScore() call below.
|
|
||||||
foreach (var s in scores)
|
|
||||||
{
|
|
||||||
await difficultyCache.GetDifficultyAsync(s.BeatmapInfo, s.Ruleset, s.Mods, cancellationToken).ConfigureAwait(false);
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
long[] totalScores = await Task.WhenAll(scores.Select(s => GetTotalScoreAsync(s, cancellationToken: cancellationToken))).ConfigureAwait(false);
|
|
||||||
|
|
||||||
return scores.Select((score, index) => (score, totalScore: totalScores[index]))
|
|
||||||
.OrderByDescending(g => g.totalScore)
|
|
||||||
.ThenBy(g => g.score.OnlineID)
|
|
||||||
.Select(g => g.score)
|
|
||||||
.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves a bindable that represents the total score of a <see cref="ScoreInfo"/>.
|
/// Retrieves a bindable that represents the total score of a <see cref="ScoreInfo"/>.
|
||||||
@ -106,44 +79,18 @@ namespace osu.Game.Scoring
|
|||||||
/// <returns>The bindable containing the formatted total score string.</returns>
|
/// <returns>The bindable containing the formatted total score string.</returns>
|
||||||
public Bindable<string> GetBindableTotalScoreString([NotNull] ScoreInfo score) => new TotalScoreStringBindable(GetBindableTotalScore(score));
|
public Bindable<string> GetBindableTotalScoreString([NotNull] ScoreInfo score) => new TotalScoreStringBindable(GetBindableTotalScore(score));
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Retrieves the total score of a <see cref="ScoreInfo"/> in the given <see cref="ScoringMode"/>.
|
|
||||||
/// The score is returned in a callback that is run on the update thread.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="score">The <see cref="ScoreInfo"/> to calculate the total score of.</param>
|
|
||||||
/// <param name="callback">The callback to be invoked with the total score.</param>
|
|
||||||
/// <param name="mode">The <see cref="ScoringMode"/> to return the total score as.</param>
|
|
||||||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the process.</param>
|
|
||||||
public void GetTotalScore([NotNull] ScoreInfo score, [NotNull] Action<long> callback, ScoringMode mode = ScoringMode.Standardised, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
GetTotalScoreAsync(score, mode, cancellationToken)
|
|
||||||
.ContinueWith(task => scheduler.Add(() =>
|
|
||||||
{
|
|
||||||
if (!cancellationToken.IsCancellationRequested)
|
|
||||||
callback(task.GetResultSafely());
|
|
||||||
}), TaskContinuationOptions.OnlyOnRanToCompletion);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the total score of a <see cref="ScoreInfo"/> in the given <see cref="ScoringMode"/>.
|
/// Retrieves the total score of a <see cref="ScoreInfo"/> in the given <see cref="ScoringMode"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="score">The <see cref="ScoreInfo"/> to calculate the total score of.</param>
|
/// <param name="score">The <see cref="ScoreInfo"/> to calculate the total score of.</param>
|
||||||
/// <param name="mode">The <see cref="ScoringMode"/> to return the total score as.</param>
|
/// <param name="mode">The <see cref="ScoringMode"/> to return the total score as.</param>
|
||||||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the process.</param>
|
|
||||||
/// <returns>The total score.</returns>
|
/// <returns>The total score.</returns>
|
||||||
public async Task<long> GetTotalScoreAsync([NotNull] ScoreInfo score, ScoringMode mode = ScoringMode.Standardised, CancellationToken cancellationToken = default)
|
public long GetTotalScore([NotNull] ScoreInfo score, ScoringMode mode = ScoringMode.Standardised)
|
||||||
{
|
{
|
||||||
// TODO: This is required for playlist aggregate scores. They should likely not be getting here in the first place.
|
// TODO: This is required for playlist aggregate scores. They should likely not be getting here in the first place.
|
||||||
if (string.IsNullOrEmpty(score.BeatmapInfo.MD5Hash))
|
if (string.IsNullOrEmpty(score.BeatmapInfo.MD5Hash))
|
||||||
return score.TotalScore;
|
return score.TotalScore;
|
||||||
|
|
||||||
int? beatmapMaxCombo = await GetMaximumAchievableComboAsync(score, cancellationToken).ConfigureAwait(false);
|
|
||||||
if (beatmapMaxCombo == null)
|
|
||||||
return score.TotalScore;
|
|
||||||
|
|
||||||
if (beatmapMaxCombo == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
var ruleset = score.Ruleset.CreateInstance();
|
var ruleset = score.Ruleset.CreateInstance();
|
||||||
var scoreProcessor = ruleset.CreateScoreProcessor();
|
var scoreProcessor = ruleset.CreateScoreProcessor();
|
||||||
scoreProcessor.Mods.Value = score.Mods;
|
scoreProcessor.Mods.Value = score.Mods;
|
||||||
@ -155,35 +102,8 @@ namespace osu.Game.Scoring
|
|||||||
/// Retrieves the maximum achievable combo for the provided score.
|
/// Retrieves the maximum achievable combo for the provided score.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="score">The <see cref="ScoreInfo"/> to compute the maximum achievable combo for.</param>
|
/// <param name="score">The <see cref="ScoreInfo"/> to compute the maximum achievable combo for.</param>
|
||||||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the process.</param>
|
/// <returns>The maximum achievable combo.</returns>
|
||||||
/// <returns>The maximum achievable combo. A <see langword="null"/> return value indicates the difficulty cache has failed to retrieve the combo.</returns>
|
public int GetMaximumAchievableCombo([NotNull] ScoreInfo score) => score.MaximumStatistics.Where(kvp => kvp.Key.AffectsCombo()).Sum(kvp => kvp.Value);
|
||||||
public async Task<int?> GetMaximumAchievableComboAsync([NotNull] ScoreInfo score, CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
if (score.IsLegacyScore)
|
|
||||||
{
|
|
||||||
// This score is guaranteed to be an osu!stable score.
|
|
||||||
// The combo must be determined through either the beatmap's max combo value or the difficulty calculator, as lazer's scoring has changed and the score statistics cannot be used.
|
|
||||||
#pragma warning disable CS0618
|
|
||||||
if (score.BeatmapInfo.MaxCombo != null)
|
|
||||||
return score.BeatmapInfo.MaxCombo.Value;
|
|
||||||
#pragma warning restore CS0618
|
|
||||||
|
|
||||||
if (difficultyCache == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// We can compute the max combo locally after the async beatmap difficulty computation.
|
|
||||||
var difficulty = await difficultyCache.GetDifficultyAsync(score.BeatmapInfo, score.Ruleset, score.Mods, cancellationToken).ConfigureAwait(false);
|
|
||||||
|
|
||||||
if (difficulty == null)
|
|
||||||
Logger.Log($"Couldn't get beatmap difficulty for beatmap {score.BeatmapInfo.OnlineID}");
|
|
||||||
|
|
||||||
return difficulty?.MaxCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is guaranteed to be a non-legacy score.
|
|
||||||
// The combo must be determined through the score's statistics, as both the beatmap's max combo and the difficulty calculator will provide osu!stable combo values.
|
|
||||||
return Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r.AffectsCombo()).Select(r => score.Statistics.GetValueOrDefault(r)).Sum();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides the total score of a <see cref="ScoreInfo"/>. Responds to changes in the currently-selected <see cref="ScoringMode"/>.
|
/// Provides the total score of a <see cref="ScoreInfo"/>. Responds to changes in the currently-selected <see cref="ScoringMode"/>.
|
||||||
@ -191,10 +111,6 @@ namespace osu.Game.Scoring
|
|||||||
private class TotalScoreBindable : Bindable<long>
|
private class TotalScoreBindable : Bindable<long>
|
||||||
{
|
{
|
||||||
private readonly Bindable<ScoringMode> scoringMode = new Bindable<ScoringMode>();
|
private readonly Bindable<ScoringMode> scoringMode = new Bindable<ScoringMode>();
|
||||||
private readonly ScoreInfo score;
|
|
||||||
private readonly ScoreManager scoreManager;
|
|
||||||
|
|
||||||
private CancellationTokenSource difficultyCalculationCancellationSource;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="TotalScoreBindable"/>.
|
/// Creates a new <see cref="TotalScoreBindable"/>.
|
||||||
@ -204,19 +120,8 @@ namespace osu.Game.Scoring
|
|||||||
/// <param name="configManager">The config.</param>
|
/// <param name="configManager">The config.</param>
|
||||||
public TotalScoreBindable(ScoreInfo score, ScoreManager scoreManager, OsuConfigManager configManager)
|
public TotalScoreBindable(ScoreInfo score, ScoreManager scoreManager, OsuConfigManager configManager)
|
||||||
{
|
{
|
||||||
this.score = score;
|
|
||||||
this.scoreManager = scoreManager;
|
|
||||||
|
|
||||||
configManager?.BindWith(OsuSetting.ScoreDisplayMode, scoringMode);
|
configManager?.BindWith(OsuSetting.ScoreDisplayMode, scoringMode);
|
||||||
scoringMode.BindValueChanged(onScoringModeChanged, true);
|
scoringMode.BindValueChanged(mode => Value = scoreManager.GetTotalScore(score, mode.NewValue), true);
|
||||||
}
|
|
||||||
|
|
||||||
private void onScoringModeChanged(ValueChangedEvent<ScoringMode> mode)
|
|
||||||
{
|
|
||||||
difficultyCalculationCancellationSource?.Cancel();
|
|
||||||
difficultyCalculationCancellationSource = new CancellationTokenSource();
|
|
||||||
|
|
||||||
scoreManager.GetTotalScore(score, s => Value = s, mode.NewValue, difficultyCalculationCancellationSource.Token);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
if (result != 0) return result;
|
if (result != 0) return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CompareReverseChildID(y, x);
|
return CompareReverseChildID(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio.Track;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -64,8 +63,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool trackWasPlaying;
|
private bool trackWasPlaying;
|
||||||
|
|
||||||
private Track track;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The timeline zoom level at a 1x zoom scale.
|
/// The timeline zoom level at a 1x zoom scale.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -93,6 +90,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
private Bindable<float> waveformOpacity;
|
private Bindable<float> waveformOpacity;
|
||||||
|
|
||||||
|
private double trackLengthForZoom;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours, OsuConfigManager config)
|
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours, OsuConfigManager config)
|
||||||
{
|
{
|
||||||
@ -144,9 +143,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
Beatmap.BindValueChanged(b =>
|
Beatmap.BindValueChanged(b =>
|
||||||
{
|
{
|
||||||
waveform.Waveform = b.NewValue.Waveform;
|
waveform.Waveform = b.NewValue.Waveform;
|
||||||
track = b.NewValue.Track;
|
|
||||||
|
|
||||||
setupTimelineZoom();
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
|
Zoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
|
||||||
@ -185,8 +181,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
private void updateWaveformOpacity() =>
|
private void updateWaveformOpacity() =>
|
||||||
waveform.FadeTo(WaveformVisible.Value ? waveformOpacity.Value : 0, 200, Easing.OutQuint);
|
waveform.FadeTo(WaveformVisible.Value ? waveformOpacity.Value : 0, 200, Easing.OutQuint);
|
||||||
|
|
||||||
private float getZoomLevelForVisibleMilliseconds(double milliseconds) => Math.Max(1, (float)(track.Length / milliseconds));
|
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -197,20 +191,21 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
// This needs to happen after transforms are updated, but before the scroll position is updated in base.UpdateAfterChildren
|
// This needs to happen after transforms are updated, but before the scroll position is updated in base.UpdateAfterChildren
|
||||||
if (editorClock.IsRunning)
|
if (editorClock.IsRunning)
|
||||||
scrollToTrackTime();
|
scrollToTrackTime();
|
||||||
}
|
|
||||||
|
|
||||||
private void setupTimelineZoom()
|
if (editorClock.TrackLength != trackLengthForZoom)
|
||||||
{
|
|
||||||
if (!track.IsLoaded)
|
|
||||||
{
|
{
|
||||||
Scheduler.AddOnce(setupTimelineZoom);
|
defaultTimelineZoom = getZoomLevelForVisibleMilliseconds(6000);
|
||||||
return;
|
|
||||||
|
float initialZoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
|
||||||
|
float minimumZoom = getZoomLevelForVisibleMilliseconds(10000);
|
||||||
|
float maximumZoom = getZoomLevelForVisibleMilliseconds(500);
|
||||||
|
|
||||||
|
SetupZoom(initialZoom, minimumZoom, maximumZoom);
|
||||||
|
|
||||||
|
float getZoomLevelForVisibleMilliseconds(double milliseconds) => Math.Max(1, (float)(editorClock.TrackLength / milliseconds));
|
||||||
|
|
||||||
|
trackLengthForZoom = editorClock.TrackLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultTimelineZoom = getZoomLevelForVisibleMilliseconds(6000);
|
|
||||||
|
|
||||||
float initialZoom = (float)(defaultTimelineZoom * editorBeatmap.BeatmapInfo.TimelineZoom);
|
|
||||||
SetupZoom(initialZoom, getZoomLevelForVisibleMilliseconds(10000), getZoomLevelForVisibleMilliseconds(500));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnScroll(ScrollEvent e)
|
protected override bool OnScroll(ScrollEvent e)
|
||||||
@ -255,16 +250,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
|
|
||||||
private void seekTrackToCurrent()
|
private void seekTrackToCurrent()
|
||||||
{
|
{
|
||||||
if (!track.IsLoaded)
|
double target = Current / Content.DrawWidth * editorClock.TrackLength;
|
||||||
return;
|
editorClock.Seek(Math.Min(editorClock.TrackLength, target));
|
||||||
|
|
||||||
double target = Current / Content.DrawWidth * track.Length;
|
|
||||||
editorClock.Seek(Math.Min(track.Length, target));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scrollToTrackTime()
|
private void scrollToTrackTime()
|
||||||
{
|
{
|
||||||
if (!track.IsLoaded || track.Length == 0)
|
if (editorClock.TrackLength == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// covers the case where the user starts playback after a drag is in progress.
|
// covers the case where the user starts playback after a drag is in progress.
|
||||||
@ -272,7 +264,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
if (handlingDragInput)
|
if (handlingDragInput)
|
||||||
editorClock.Stop();
|
editorClock.Stop();
|
||||||
|
|
||||||
ScrollTo((float)(editorClock.CurrentTime / track.Length) * Content.DrawWidth, false);
|
ScrollTo((float)(editorClock.CurrentTime / editorClock.TrackLength) * Content.DrawWidth, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
@ -310,12 +302,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The total amount of time visible on the timeline.
|
/// The total amount of time visible on the timeline.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double VisibleRange => track.Length / Zoom;
|
public double VisibleRange => editorClock.TrackLength / Zoom;
|
||||||
|
|
||||||
public SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition, SnapType snapType = SnapType.All) =>
|
public SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition, SnapType snapType = SnapType.All) =>
|
||||||
new SnapResult(screenSpacePosition, beatSnapProvider.SnapTime(getTimeFromPosition(Content.ToLocalSpace(screenSpacePosition))));
|
new SnapResult(screenSpacePosition, beatSnapProvider.SnapTime(getTimeFromPosition(Content.ToLocalSpace(screenSpacePosition))));
|
||||||
|
|
||||||
private double getTimeFromPosition(Vector2 localPosition) =>
|
private double getTimeFromPosition(Vector2 localPosition) =>
|
||||||
(localPosition.X / Content.DrawWidth) * track.Length;
|
(localPosition.X / Content.DrawWidth) * editorClock.TrackLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
|
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
|
||||||
clock = new EditorClock(playableBeatmap, beatDivisor) { IsCoupled = false };
|
clock = new EditorClock(playableBeatmap, beatDivisor);
|
||||||
clock.ChangeSource(loadableBeatmap.Track);
|
clock.ChangeSource(loadableBeatmap.Track);
|
||||||
|
|
||||||
dependencies.CacheAs(clock);
|
dependencies.CacheAs(clock);
|
||||||
|
@ -4,10 +4,12 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Audio.Track;
|
using osu.Framework.Audio.Track;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Transforms;
|
using osu.Framework.Graphics.Transforms;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
@ -19,7 +21,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A decoupled clock which adds editor-specific functionality, such as snapping to a user-defined beat divisor.
|
/// A decoupled clock which adds editor-specific functionality, such as snapping to a user-defined beat divisor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EditorClock : Component, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
|
public class EditorClock : CompositeComponent, IFrameBasedClock, IAdjustableClock, ISourceChangeableClock
|
||||||
{
|
{
|
||||||
public IBindable<Track> Track => track;
|
public IBindable<Track> Track => track;
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
private readonly BindableBeatDivisor beatDivisor;
|
private readonly BindableBeatDivisor beatDivisor;
|
||||||
|
|
||||||
private readonly DecoupleableInterpolatingFramedClock underlyingClock;
|
private readonly FramedBeatmapClock underlyingClock;
|
||||||
|
|
||||||
private bool playbackFinished;
|
private bool playbackFinished;
|
||||||
|
|
||||||
@ -52,7 +54,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
this.beatDivisor = beatDivisor ?? new BindableBeatDivisor();
|
this.beatDivisor = beatDivisor ?? new BindableBeatDivisor();
|
||||||
|
|
||||||
underlyingClock = new DecoupleableInterpolatingFramedClock();
|
underlyingClock = new FramedBeatmapClock(applyOffsets: true) { IsCoupled = false };
|
||||||
|
AddInternal(underlyingClock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -155,6 +158,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public double CurrentTime => underlyingClock.CurrentTime;
|
public double CurrentTime => underlyingClock.CurrentTime;
|
||||||
|
|
||||||
|
public double TotalAppliedOffset => underlyingClock.TotalAppliedOffset;
|
||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
ClearTransforms();
|
ClearTransforms();
|
||||||
@ -219,18 +224,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public void ProcessFrame()
|
public void ProcessFrame()
|
||||||
{
|
{
|
||||||
underlyingClock.ProcessFrame();
|
// Noop to ensure an external consumer doesn't process the internal clock an extra time.
|
||||||
|
|
||||||
playbackFinished = CurrentTime >= TrackLength;
|
|
||||||
|
|
||||||
if (playbackFinished)
|
|
||||||
{
|
|
||||||
if (IsRunning)
|
|
||||||
underlyingClock.Stop();
|
|
||||||
|
|
||||||
if (CurrentTime > TrackLength)
|
|
||||||
underlyingClock.Seek(TrackLength);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime;
|
public double ElapsedFrameTime => underlyingClock.ElapsedFrameTime;
|
||||||
@ -247,18 +241,26 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public IClock Source => underlyingClock.Source;
|
public IClock Source => underlyingClock.Source;
|
||||||
|
|
||||||
public bool IsCoupled
|
|
||||||
{
|
|
||||||
get => underlyingClock.IsCoupled;
|
|
||||||
set => underlyingClock.IsCoupled = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private const double transform_time = 300;
|
private const double transform_time = 300;
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
|
// EditorClock wasn't being added in many places. This gives us more certainty that it is.
|
||||||
|
Debug.Assert(underlyingClock.LoadState > LoadState.NotLoaded);
|
||||||
|
|
||||||
|
playbackFinished = CurrentTime >= TrackLength;
|
||||||
|
|
||||||
|
if (playbackFinished)
|
||||||
|
{
|
||||||
|
if (IsRunning)
|
||||||
|
underlyingClock.Stop();
|
||||||
|
|
||||||
|
if (CurrentTime > TrackLength)
|
||||||
|
underlyingClock.Seek(TrackLength);
|
||||||
|
}
|
||||||
|
|
||||||
updateSeekingState();
|
updateSeekingState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
public MatchTypePicker TypePicker;
|
public MatchTypePicker TypePicker;
|
||||||
public OsuEnumDropdown<QueueMode> QueueModeDropdown;
|
public OsuEnumDropdown<QueueMode> QueueModeDropdown;
|
||||||
public OsuTextBox PasswordTextBox;
|
public OsuTextBox PasswordTextBox;
|
||||||
|
public OsuCheckbox AutoSkipCheckbox;
|
||||||
public TriangleButton ApplyButton;
|
public TriangleButton ApplyButton;
|
||||||
|
|
||||||
public OsuSpriteText ErrorText;
|
public OsuSpriteText ErrorText;
|
||||||
@ -249,6 +250,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
LengthLimit = 255,
|
LengthLimit = 255,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
new Section("Other")
|
||||||
|
{
|
||||||
|
Child = AutoSkipCheckbox = new OsuCheckbox
|
||||||
|
{
|
||||||
|
LabelText = "Automatically skip the beatmap intro"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -343,6 +351,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
Password.BindValueChanged(password => PasswordTextBox.Text = password.NewValue ?? string.Empty, true);
|
Password.BindValueChanged(password => PasswordTextBox.Text = password.NewValue ?? string.Empty, true);
|
||||||
QueueMode.BindValueChanged(mode => QueueModeDropdown.Current.Value = mode.NewValue, true);
|
QueueMode.BindValueChanged(mode => QueueModeDropdown.Current.Value = mode.NewValue, true);
|
||||||
AutoStartDuration.BindValueChanged(duration => startModeDropdown.Current.Value = (StartMode)(int)duration.NewValue.TotalSeconds, true);
|
AutoStartDuration.BindValueChanged(duration => startModeDropdown.Current.Value = (StartMode)(int)duration.NewValue.TotalSeconds, true);
|
||||||
|
AutoSkip.BindValueChanged(autoSkip => AutoSkipCheckbox.Current.Value = autoSkip.NewValue, true);
|
||||||
|
|
||||||
operationInProgress.BindTo(ongoingOperationTracker.InProgress);
|
operationInProgress.BindTo(ongoingOperationTracker.InProgress);
|
||||||
operationInProgress.BindValueChanged(v =>
|
operationInProgress.BindValueChanged(v =>
|
||||||
@ -390,7 +399,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
password: PasswordTextBox.Text,
|
password: PasswordTextBox.Text,
|
||||||
matchType: TypePicker.Current.Value,
|
matchType: TypePicker.Current.Value,
|
||||||
queueMode: QueueModeDropdown.Current.Value,
|
queueMode: QueueModeDropdown.Current.Value,
|
||||||
autoStartDuration: autoStartDuration)
|
autoStartDuration: autoStartDuration,
|
||||||
|
autoSkip: AutoSkipCheckbox.Current.Value)
|
||||||
.ContinueWith(t => Schedule(() =>
|
.ContinueWith(t => Schedule(() =>
|
||||||
{
|
{
|
||||||
if (t.IsCompletedSuccessfully)
|
if (t.IsCompletedSuccessfully)
|
||||||
@ -406,6 +416,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
room.Password.Value = PasswordTextBox.Current.Value;
|
room.Password.Value = PasswordTextBox.Current.Value;
|
||||||
room.QueueMode.Value = QueueModeDropdown.Current.Value;
|
room.QueueMode.Value = QueueModeDropdown.Current.Value;
|
||||||
room.AutoStartDuration.Value = autoStartDuration;
|
room.AutoStartDuration.Value = autoStartDuration;
|
||||||
|
room.AutoSkip.Value = AutoSkipCheckbox.Current.Value;
|
||||||
|
|
||||||
if (int.TryParse(MaxParticipantsField.Text, out int max))
|
if (int.TryParse(MaxParticipantsField.Text, out int max))
|
||||||
room.MaxParticipants.Value = max;
|
room.MaxParticipants.Value = max;
|
||||||
|
@ -61,7 +61,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
{
|
{
|
||||||
AllowPause = false,
|
AllowPause = false,
|
||||||
AllowRestart = false,
|
AllowRestart = false,
|
||||||
AllowSkipping = false,
|
AllowSkipping = room.AutoSkip.Value,
|
||||||
|
AutomaticallySkipIntro = room.AutoSkip.Value
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
this.users = users;
|
this.users = users;
|
||||||
|
@ -86,6 +86,9 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
[Resolved(typeof(Room))]
|
[Resolved(typeof(Room))]
|
||||||
protected Bindable<TimeSpan> AutoStartDuration { get; private set; }
|
protected Bindable<TimeSpan> AutoStartDuration { get; private set; }
|
||||||
|
|
||||||
|
[Resolved(typeof(Room))]
|
||||||
|
protected Bindable<bool> AutoSkip { get; private set; }
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private IBindable<PlaylistItem> subScreenSelectedItem { get; set; }
|
private IBindable<PlaylistItem> subScreenSelectedItem { get; set; }
|
||||||
|
|
||||||
|
@ -180,31 +180,26 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
|||||||
/// <param name="callback">The callback to invoke with the final <see cref="ScoreInfo"/>s.</param>
|
/// <param name="callback">The callback to invoke with the final <see cref="ScoreInfo"/>s.</param>
|
||||||
/// <param name="scores">The <see cref="MultiplayerScore"/>s that were retrieved from <see cref="APIRequest"/>s.</param>
|
/// <param name="scores">The <see cref="MultiplayerScore"/>s that were retrieved from <see cref="APIRequest"/>s.</param>
|
||||||
/// <param name="pivot">An optional pivot around which the scores were retrieved.</param>
|
/// <param name="pivot">An optional pivot around which the scores were retrieved.</param>
|
||||||
private void performSuccessCallback([NotNull] Action<IEnumerable<ScoreInfo>> callback, [NotNull] List<MultiplayerScore> scores, [CanBeNull] MultiplayerScores pivot = null)
|
private void performSuccessCallback([NotNull] Action<IEnumerable<ScoreInfo>> callback, [NotNull] List<MultiplayerScore> scores, [CanBeNull] MultiplayerScores pivot = null) => Schedule(() =>
|
||||||
{
|
{
|
||||||
var scoreInfos = scores.Select(s => s.CreateScoreInfo(rulesets, playlistItem, Beatmap.Value.BeatmapInfo)).ToArray();
|
var scoreInfos = scoreManager.OrderByTotalScore(scores.Select(s => s.CreateScoreInfo(rulesets, playlistItem, Beatmap.Value.BeatmapInfo))).ToArray();
|
||||||
|
|
||||||
// Score panels calculate total score before displaying, which can take some time. In order to count that calculation as part of the loading spinner display duration,
|
// Select a score if we don't already have one selected.
|
||||||
// calculate the total scores locally before invoking the success callback.
|
// Note: This is done before the callback so that the panel list centres on the selected score before panels are added (eliminating initial scroll).
|
||||||
scoreManager.OrderByTotalScoreAsync(scoreInfos).ContinueWith(_ => Schedule(() =>
|
if (SelectedScore.Value == null)
|
||||||
{
|
{
|
||||||
// Select a score if we don't already have one selected.
|
Schedule(() =>
|
||||||
// Note: This is done before the callback so that the panel list centres on the selected score before panels are added (eliminating initial scroll).
|
|
||||||
if (SelectedScore.Value == null)
|
|
||||||
{
|
{
|
||||||
Schedule(() =>
|
// Prefer selecting the local user's score, or otherwise default to the first visible score.
|
||||||
{
|
SelectedScore.Value = scoreInfos.FirstOrDefault(s => s.User.OnlineID == api.LocalUser.Value.Id) ?? scoreInfos.FirstOrDefault();
|
||||||
// Prefer selecting the local user's score, or otherwise default to the first visible score.
|
});
|
||||||
SelectedScore.Value = scoreInfos.FirstOrDefault(s => s.User.OnlineID == api.LocalUser.Value.Id) ?? scoreInfos.FirstOrDefault();
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Invoke callback to add the scores. Exclude the user's current score which was added previously.
|
// Invoke callback to add the scores. Exclude the user's current score which was added previously.
|
||||||
callback.Invoke(scoreInfos.Where(s => s.OnlineID != Score?.OnlineID));
|
callback.Invoke(scoreInfos.Where(s => s.OnlineID != Score?.OnlineID));
|
||||||
|
|
||||||
hideLoadingSpinners(pivot);
|
hideLoadingSpinners(pivot);
|
||||||
}));
|
});
|
||||||
}
|
|
||||||
|
|
||||||
private void hideLoadingSpinners([CanBeNull] MultiplayerScores pivot = null)
|
private void hideLoadingSpinners([CanBeNull] MultiplayerScores pivot = null)
|
||||||
{
|
{
|
||||||
|
@ -88,9 +88,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
ensureSourceClockSet();
|
ensureSourceClockSet();
|
||||||
|
|
||||||
// Seeking the decoupled clock to its current time ensures that its source clock will be seeked to the same time
|
PrepareStart();
|
||||||
// This accounts for the clock source potentially taking time to enter a completely stopped state
|
|
||||||
Seek(GameplayClock.CurrentTime);
|
|
||||||
|
|
||||||
// The case which caused this to be added is FrameStabilityContainer, which manages its own current and elapsed time.
|
// The case which caused this to be added is FrameStabilityContainer, which manages its own current and elapsed time.
|
||||||
// Because we generally update our own current time quicker than children can query it (via Start/Seek/Update),
|
// Because we generally update our own current time quicker than children can query it (via Start/Seek/Update),
|
||||||
@ -111,11 +109,19 @@ namespace osu.Game.Screens.Play
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When <see cref="Start"/> is called, this will be run to give an opportunity to prepare the clock at the correct
|
||||||
|
/// start location.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void PrepareStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Seek to a specific time in gameplay.
|
/// Seek to a specific time in gameplay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="time">The destination time to seek to.</param>
|
/// <param name="time">The destination time to seek to.</param>
|
||||||
public void Seek(double time)
|
public virtual void Seek(double time)
|
||||||
{
|
{
|
||||||
Logger.Log($"{nameof(GameplayClockContainer)} seeking to {time}");
|
Logger.Log($"{nameof(GameplayClockContainer)} seeking to {time}");
|
||||||
|
|
||||||
|
@ -45,6 +45,17 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private readonly List<Bindable<double>> nonGameplayAdjustments = new List<Bindable<double>>();
|
private readonly List<Bindable<double>> nonGameplayAdjustments = new List<Bindable<double>>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stores the time at which the last <see cref="StopGameplayClock"/> call was triggered.
|
||||||
|
/// This is used to ensure we resume from that precise point in time, ignoring the proceeding frequency ramp.
|
||||||
|
///
|
||||||
|
/// Optimally, we'd have gameplay ramp down with the frequency, but I believe this was intentionally disabled
|
||||||
|
/// to avoid fails occurring after the pause screen has been shown.
|
||||||
|
///
|
||||||
|
/// In the future I want to change this.
|
||||||
|
/// </summary>
|
||||||
|
private double? actualStopTime;
|
||||||
|
|
||||||
public override IEnumerable<double> NonGameplayAdjustments => nonGameplayAdjustments.Select(b => b.Value);
|
public override IEnumerable<double> NonGameplayAdjustments => nonGameplayAdjustments.Select(b => b.Value);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -86,6 +97,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
protected override void StopGameplayClock()
|
protected override void StopGameplayClock()
|
||||||
{
|
{
|
||||||
|
actualStopTime = GameplayClock.CurrentTime;
|
||||||
|
|
||||||
if (IsLoaded)
|
if (IsLoaded)
|
||||||
{
|
{
|
||||||
// During normal operation, the source is stopped after performing a frequency ramp.
|
// During normal operation, the source is stopped after performing a frequency ramp.
|
||||||
@ -108,6 +121,25 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Seek(double time)
|
||||||
|
{
|
||||||
|
// Safety in case the clock is seeked while stopped.
|
||||||
|
actualStopTime = null;
|
||||||
|
|
||||||
|
base.Seek(time);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void PrepareStart()
|
||||||
|
{
|
||||||
|
if (actualStopTime != null)
|
||||||
|
{
|
||||||
|
Seek(actualStopTime.Value);
|
||||||
|
actualStopTime = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
base.PrepareStart();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void StartGameplayClock()
|
protected override void StartGameplayClock()
|
||||||
{
|
{
|
||||||
addSourceClockAdjustments();
|
addSourceClockAdjustments();
|
||||||
|
@ -363,7 +363,7 @@ namespace osu.Game.Screens.Play
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
CurrentPlayer = createPlayer();
|
CurrentPlayer = createPlayer();
|
||||||
CurrentPlayer.Configuration.AutomaticallySkipIntro = quickRestart;
|
CurrentPlayer.Configuration.AutomaticallySkipIntro |= quickRestart;
|
||||||
CurrentPlayer.RestartCount = restartCount++;
|
CurrentPlayer.RestartCount = restartCount++;
|
||||||
CurrentPlayer.RestartRequested = restartRequested;
|
CurrentPlayer.RestartRequested = restartRequested;
|
||||||
|
|
||||||
@ -530,7 +530,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private void load(OsuColour colours, AudioManager audioManager, INotificationOverlay notificationOverlay, VolumeOverlay volumeOverlay)
|
private void load(OsuColour colours, AudioManager audioManager, INotificationOverlay notificationOverlay, VolumeOverlay volumeOverlay)
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.VolumeMute;
|
Icon = FontAwesome.Solid.VolumeMute;
|
||||||
IconBackground.Colour = colours.RedDark;
|
IconContent.Colour = colours.RedDark;
|
||||||
|
|
||||||
Activated = delegate
|
Activated = delegate
|
||||||
{
|
{
|
||||||
@ -584,7 +584,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private void load(OsuColour colours, INotificationOverlay notificationOverlay)
|
private void load(OsuColour colours, INotificationOverlay notificationOverlay)
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.Solid.BatteryQuarter;
|
Icon = FontAwesome.Solid.BatteryQuarter;
|
||||||
IconBackground.Colour = colours.RedDark;
|
IconContent.Colour = colours.RedDark;
|
||||||
|
|
||||||
Activated = delegate
|
Activated = delegate
|
||||||
{
|
{
|
||||||
|
@ -114,16 +114,17 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
displayTime = gameplayClock.CurrentTime;
|
||||||
|
|
||||||
// skip is not required if there is no extra "empty" time to skip.
|
// skip is not required if there is no extra "empty" time to skip.
|
||||||
// we may need to remove this if rewinding before the initial player load position becomes a thing.
|
// we may need to remove this if rewinding before the initial player load position becomes a thing.
|
||||||
if (fadeOutBeginTime < gameplayClock.CurrentTime)
|
if (fadeOutBeginTime <= displayTime)
|
||||||
{
|
{
|
||||||
Expire();
|
Expire();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
button.Action = () => RequestSkip?.Invoke();
|
button.Action = () => RequestSkip?.Invoke();
|
||||||
displayTime = gameplayClock.CurrentTime;
|
|
||||||
|
|
||||||
fadeContainer.TriggerShow();
|
fadeContainer.TriggerShow();
|
||||||
|
|
||||||
@ -146,7 +147,12 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
double progress = fadeOutBeginTime <= displayTime ? 1 : Math.Max(0, 1 - (gameplayClock.CurrentTime - displayTime) / (fadeOutBeginTime - displayTime));
|
// This case causes an immediate expire in `LoadComplete`, but `Update` may run once after that.
|
||||||
|
// Avoid div-by-zero below.
|
||||||
|
if (fadeOutBeginTime <= displayTime)
|
||||||
|
return;
|
||||||
|
|
||||||
|
double progress = Math.Max(0, 1 - (gameplayClock.CurrentTime - displayTime) / (fadeOutBeginTime - displayTime));
|
||||||
|
|
||||||
remainingTimeBox.Width = (float)Interpolation.Lerp(remainingTimeBox.Width, progress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
remainingTimeBox.Width = (float)Interpolation.Lerp(remainingTimeBox.Width, progress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
||||||
|
|
||||||
|
@ -67,12 +67,10 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
|
var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
|
||||||
string creator = metadata.Author.Username;
|
string creator = metadata.Author.Username;
|
||||||
|
|
||||||
int? beatmapMaxCombo = scoreManager.GetMaximumAchievableComboAsync(score).GetResultSafely();
|
|
||||||
|
|
||||||
var topStatistics = new List<StatisticDisplay>
|
var topStatistics = new List<StatisticDisplay>
|
||||||
{
|
{
|
||||||
new AccuracyStatistic(score.Accuracy),
|
new AccuracyStatistic(score.Accuracy),
|
||||||
new ComboStatistic(score.MaxCombo, beatmapMaxCombo),
|
new ComboStatistic(score.MaxCombo, scoreManager.GetMaximumAchievableCombo(score)),
|
||||||
new PerformanceStatistic(score),
|
new PerformanceStatistic(score),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user