mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 15:47:26 +08:00
Merge remote-tracking branch 'refs/remotes/ppy/master' into no-comments-placeholder
This commit is contained in:
commit
de6a71ffb7
@ -118,17 +118,19 @@ namespace osu.Game.Tests.Editor
|
||||
[Test]
|
||||
public void TestGetSnappedDurationFromDistance()
|
||||
{
|
||||
assertSnappedDuration(50, 0);
|
||||
assertSnappedDuration(0, 0);
|
||||
assertSnappedDuration(50, 1000);
|
||||
assertSnappedDuration(100, 1000);
|
||||
assertSnappedDuration(150, 1000);
|
||||
assertSnappedDuration(150, 2000);
|
||||
assertSnappedDuration(200, 2000);
|
||||
assertSnappedDuration(250, 2000);
|
||||
assertSnappedDuration(250, 3000);
|
||||
|
||||
AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
|
||||
|
||||
assertSnappedDuration(0, 0);
|
||||
assertSnappedDuration(50, 0);
|
||||
assertSnappedDuration(100, 0);
|
||||
assertSnappedDuration(150, 0);
|
||||
assertSnappedDuration(100, 1000);
|
||||
assertSnappedDuration(150, 1000);
|
||||
assertSnappedDuration(200, 1000);
|
||||
assertSnappedDuration(250, 1000);
|
||||
|
||||
@ -139,8 +141,8 @@ namespace osu.Game.Tests.Editor
|
||||
});
|
||||
|
||||
assertSnappedDuration(50, 0);
|
||||
assertSnappedDuration(100, 0);
|
||||
assertSnappedDuration(150, 0);
|
||||
assertSnappedDuration(100, 500);
|
||||
assertSnappedDuration(150, 500);
|
||||
assertSnappedDuration(200, 500);
|
||||
assertSnappedDuration(250, 500);
|
||||
assertSnappedDuration(400, 1000);
|
||||
@ -149,17 +151,17 @@ namespace osu.Game.Tests.Editor
|
||||
[Test]
|
||||
public void GetSnappedDistanceFromDistance()
|
||||
{
|
||||
assertSnappedDistance(50, 0);
|
||||
assertSnappedDistance(50, 100);
|
||||
assertSnappedDistance(100, 100);
|
||||
assertSnappedDistance(150, 100);
|
||||
assertSnappedDistance(150, 200);
|
||||
assertSnappedDistance(200, 200);
|
||||
assertSnappedDistance(250, 200);
|
||||
assertSnappedDistance(250, 300);
|
||||
|
||||
AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
|
||||
|
||||
assertSnappedDistance(50, 0);
|
||||
assertSnappedDistance(100, 0);
|
||||
assertSnappedDistance(150, 0);
|
||||
assertSnappedDistance(100, 200);
|
||||
assertSnappedDistance(150, 200);
|
||||
assertSnappedDistance(200, 200);
|
||||
assertSnappedDistance(250, 200);
|
||||
|
||||
@ -170,8 +172,8 @@ namespace osu.Game.Tests.Editor
|
||||
});
|
||||
|
||||
assertSnappedDistance(50, 0);
|
||||
assertSnappedDistance(100, 0);
|
||||
assertSnappedDistance(150, 0);
|
||||
assertSnappedDistance(100, 200);
|
||||
assertSnappedDistance(150, 200);
|
||||
assertSnappedDistance(200, 200);
|
||||
assertSnappedDistance(250, 200);
|
||||
assertSnappedDistance(400, 400);
|
||||
|
@ -85,64 +85,64 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CreateContent(Vector2 startPosition)
|
||||
protected override void CreateContent()
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5),
|
||||
Position = startPosition
|
||||
Position = StartPosition
|
||||
});
|
||||
|
||||
int beatIndex = 0;
|
||||
int indexFromPlacement = 0;
|
||||
|
||||
for (float s = startPosition.X + DistanceSpacing; s <= DrawWidth && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
|
||||
for (float s = StartPosition.X + DistanceSpacing; s <= DrawWidth && indexFromPlacement < MaxIntervals; s += DistanceSpacing, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5, 10),
|
||||
Position = new Vector2(s, startPosition.Y),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
Position = new Vector2(s, StartPosition.Y),
|
||||
Colour = GetColourForIndexFromPlacement(indexFromPlacement)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
indexFromPlacement = 0;
|
||||
|
||||
for (float s = startPosition.X - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
|
||||
for (float s = StartPosition.X - DistanceSpacing; s >= 0 && indexFromPlacement < MaxIntervals; s -= DistanceSpacing, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5, 10),
|
||||
Position = new Vector2(s, startPosition.Y),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
Position = new Vector2(s, StartPosition.Y),
|
||||
Colour = GetColourForIndexFromPlacement(indexFromPlacement)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
indexFromPlacement = 0;
|
||||
|
||||
for (float s = startPosition.Y + DistanceSpacing; s <= DrawHeight && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
|
||||
for (float s = StartPosition.Y + DistanceSpacing; s <= DrawHeight && indexFromPlacement < MaxIntervals; s += DistanceSpacing, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(10, 5),
|
||||
Position = new Vector2(startPosition.X, s),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
Position = new Vector2(StartPosition.X, s),
|
||||
Colour = GetColourForIndexFromPlacement(indexFromPlacement)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
indexFromPlacement = 0;
|
||||
|
||||
for (float s = startPosition.Y - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
|
||||
for (float s = StartPosition.Y - DistanceSpacing; s >= 0 && indexFromPlacement < MaxIntervals; s -= DistanceSpacing, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(10, 5),
|
||||
Position = new Vector2(startPosition.X, s),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
Position = new Vector2(StartPosition.X, s),
|
||||
Colour = GetColourForIndexFromPlacement(indexFromPlacement)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,146 +1,15 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneTimelineBlueprintContainer : EditorClockTestScene
|
||||
public class TestSceneTimelineBlueprintContainer : TimelineTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(TimelineArea),
|
||||
typeof(Timeline),
|
||||
typeof(TimelineButton),
|
||||
typeof(CentreMarker)
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
Beatmap.Value = new WaveformTestBeatmap(audio);
|
||||
|
||||
var editorBeatmap = new EditorBeatmap((Beatmap<HitObject>)Beatmap.Value.Beatmap, BeatDivisor);
|
||||
|
||||
Dependencies.Cache(editorBeatmap);
|
||||
Dependencies.CacheAs<IBeatSnapProvider>(editorBeatmap);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new StartStopButton(),
|
||||
new AudioVisualiser(),
|
||||
}
|
||||
},
|
||||
new TimelineArea
|
||||
{
|
||||
Child = new TimelineBlueprintContainer(),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Size = new Vector2(0.8f, 100)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class AudioVisualiser : CompositeDrawable
|
||||
{
|
||||
private readonly Drawable marker;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IAdjustableClock adjustableClock { get; set; }
|
||||
|
||||
public AudioVisualiser()
|
||||
{
|
||||
Size = new Vector2(250, 25);
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.25f,
|
||||
},
|
||||
marker = new Box
|
||||
{
|
||||
RelativePositionAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 2,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (beatmap.Value.Track.IsLoaded)
|
||||
marker.X = (float)(adjustableClock.CurrentTime / beatmap.Value.Track.Length);
|
||||
}
|
||||
}
|
||||
|
||||
private class StartStopButton : OsuButton
|
||||
{
|
||||
private IAdjustableClock adjustableClock;
|
||||
private bool started;
|
||||
|
||||
public StartStopButton()
|
||||
{
|
||||
BackgroundColour = Color4.SlateGray;
|
||||
Size = new Vector2(100, 50);
|
||||
Text = "Start";
|
||||
|
||||
Action = onClick;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAdjustableClock adjustableClock)
|
||||
{
|
||||
this.adjustableClock = adjustableClock;
|
||||
}
|
||||
|
||||
private void onClick()
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
adjustableClock.Stop();
|
||||
Text = "Start";
|
||||
}
|
||||
else
|
||||
{
|
||||
adjustableClock.Start();
|
||||
Text = "Stop";
|
||||
}
|
||||
|
||||
started = !started;
|
||||
}
|
||||
}
|
||||
public override Drawable CreateTestComponent() => new TimelineBlueprintContainer();
|
||||
}
|
||||
}
|
||||
|
32
osu.Game.Tests/Visual/Editor/TestSceneTimelineTickDisplay.cs
Normal file
32
osu.Game.Tests/Visual/Editor/TestSceneTimelineTickDisplay.cs
Normal file
@ -0,0 +1,32 @@
|
||||
// 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 NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
[TestFixture]
|
||||
public class TestSceneTimelineTickDisplay : TimelineTestScene
|
||||
{
|
||||
public override Drawable CreateTestComponent() => new TimelineTickDisplay();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
BeatDivisor.Value = 4;
|
||||
|
||||
Add(new BeatDivisorControl(BeatDivisor)
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Margin = new MarginPadding(30),
|
||||
Size = new Vector2(90)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
148
osu.Game.Tests/Visual/Editor/TimelineTestScene.cs
Normal file
148
osu.Game.Tests/Visual/Editor/TimelineTestScene.cs
Normal file
@ -0,0 +1,148 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
public abstract class TimelineTestScene : EditorClockTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(TimelineArea),
|
||||
typeof(Timeline),
|
||||
typeof(TimelineButton),
|
||||
typeof(CentreMarker)
|
||||
};
|
||||
|
||||
protected TimelineArea TimelineArea { get; private set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
Beatmap.Value = new WaveformTestBeatmap(audio);
|
||||
|
||||
var editorBeatmap = new EditorBeatmap((Beatmap<HitObject>)Beatmap.Value.Beatmap, BeatDivisor);
|
||||
|
||||
Dependencies.Cache(editorBeatmap);
|
||||
Dependencies.CacheAs<IBeatSnapProvider>(editorBeatmap);
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new StartStopButton(),
|
||||
new AudioVisualiser(),
|
||||
}
|
||||
},
|
||||
TimelineArea = new TimelineArea
|
||||
{
|
||||
Child = CreateTestComponent(),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Size = new Vector2(0.8f, 100),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public abstract Drawable CreateTestComponent();
|
||||
|
||||
private class AudioVisualiser : CompositeDrawable
|
||||
{
|
||||
private readonly Drawable marker;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IAdjustableClock adjustableClock { get; set; }
|
||||
|
||||
public AudioVisualiser()
|
||||
{
|
||||
Size = new Vector2(250, 25);
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0.25f,
|
||||
},
|
||||
marker = new Box
|
||||
{
|
||||
RelativePositionAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 2,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (beatmap.Value.Track.IsLoaded)
|
||||
marker.X = (float)(adjustableClock.CurrentTime / beatmap.Value.Track.Length);
|
||||
}
|
||||
}
|
||||
|
||||
private class StartStopButton : OsuButton
|
||||
{
|
||||
private IAdjustableClock adjustableClock;
|
||||
private bool started;
|
||||
|
||||
public StartStopButton()
|
||||
{
|
||||
BackgroundColour = Color4.SlateGray;
|
||||
Size = new Vector2(100, 50);
|
||||
Text = "Start";
|
||||
|
||||
Action = onClick;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IAdjustableClock adjustableClock)
|
||||
{
|
||||
this.adjustableClock = adjustableClock;
|
||||
}
|
||||
|
||||
private void onClick()
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
adjustableClock.Stop();
|
||||
Text = "Start";
|
||||
}
|
||||
else
|
||||
{
|
||||
adjustableClock.Start();
|
||||
Text = "Stop";
|
||||
}
|
||||
|
||||
started = !started;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
122
osu.Game.Tests/Visual/Navigation/OsuGameTestScene.cs
Normal file
122
osu.Game.Tests/Visual/Navigation/OsuGameTestScene.cs
Normal file
@ -0,0 +1,122 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osuTK.Graphics;
|
||||
using IntroSequence = osu.Game.Configuration.IntroSequence;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
/// <summary>
|
||||
/// A scene which tests full game flow.
|
||||
/// </summary>
|
||||
public abstract class OsuGameTestScene : ManualInputManagerTestScene
|
||||
{
|
||||
private GameHost host;
|
||||
|
||||
protected TestOsuGame Game;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host)
|
||||
{
|
||||
this.host = host;
|
||||
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
};
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("Create new game instance", () =>
|
||||
{
|
||||
if (Game != null)
|
||||
{
|
||||
Remove(Game);
|
||||
Game.Dispose();
|
||||
}
|
||||
|
||||
RecycleLocalStorage();
|
||||
|
||||
// see MouseSettings
|
||||
var frameworkConfig = host.Dependencies.Get<FrameworkConfigManager>();
|
||||
frameworkConfig.GetBindable<double>(FrameworkSetting.CursorSensitivity).Disabled = false;
|
||||
|
||||
Game = new TestOsuGame(LocalStorage, API);
|
||||
Game.SetHost(host);
|
||||
|
||||
// todo: this can be removed once we can run audio tracks without a device present
|
||||
// see https://github.com/ppy/osu/issues/1302
|
||||
Game.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles);
|
||||
|
||||
Add(Game);
|
||||
});
|
||||
|
||||
AddUntilStep("Wait for load", () => Game.IsLoaded);
|
||||
AddUntilStep("Wait for intro", () => Game.ScreenStack.CurrentScreen is IntroScreen);
|
||||
|
||||
ConfirmAtMainMenu();
|
||||
}
|
||||
|
||||
protected void ConfirmAtMainMenu() => AddUntilStep("Wait for main menu", () => Game.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);
|
||||
|
||||
public class TestOsuGame : OsuGame
|
||||
{
|
||||
public new ScreenStack ScreenStack => base.ScreenStack;
|
||||
|
||||
public new BackButton BackButton => base.BackButton;
|
||||
|
||||
public new BeatmapManager BeatmapManager => base.BeatmapManager;
|
||||
|
||||
public new SettingsPanel Settings => base.Settings;
|
||||
|
||||
public new OsuConfigManager LocalConfig => base.LocalConfig;
|
||||
|
||||
public new Bindable<WorkingBeatmap> Beatmap => base.Beatmap;
|
||||
|
||||
public new Bindable<RulesetInfo> Ruleset => base.Ruleset;
|
||||
|
||||
protected override Loader CreateLoader() => new TestLoader();
|
||||
|
||||
public TestOsuGame(Storage storage, IAPIProvider api)
|
||||
{
|
||||
Storage = storage;
|
||||
API = api;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
API.Login("Rhythm Champion", "osu!");
|
||||
}
|
||||
}
|
||||
|
||||
public class TestLoader : Loader
|
||||
{
|
||||
protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler();
|
||||
|
||||
private class TestShaderPrecompiler : ShaderPrecompiler
|
||||
{
|
||||
protected override bool AllLoaded => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
111
osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs
Normal file
111
osu.Game.Tests/Visual/Navigation/TestScenePresentBeatmap.cs
Normal file
@ -0,0 +1,111 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Menu;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
public class TestScenePresentBeatmap : OsuGameTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestFromMainMenu()
|
||||
{
|
||||
var firstImport = importBeatmap(1);
|
||||
presentAndConfirm(firstImport);
|
||||
|
||||
AddStep("return to menu", () => Game.ScreenStack.CurrentScreen.Exit());
|
||||
AddUntilStep("wait for menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
|
||||
|
||||
var secondimport = importBeatmap(2);
|
||||
presentAndConfirm(secondimport);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Ignore("will be fixed soon")]
|
||||
public void TestFromMainMenuDifferentRuleset()
|
||||
{
|
||||
var firstImport = importBeatmap(1);
|
||||
presentAndConfirm(firstImport);
|
||||
|
||||
AddStep("return to menu", () => Game.ScreenStack.CurrentScreen.Exit());
|
||||
AddUntilStep("wait for menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
|
||||
|
||||
var secondimport = importBeatmap(2, new ManiaRuleset().RulesetInfo);
|
||||
presentAndConfirm(secondimport);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFromSongSelect()
|
||||
{
|
||||
var firstImport = importBeatmap(1);
|
||||
presentAndConfirm(firstImport);
|
||||
|
||||
var secondimport = importBeatmap(2);
|
||||
presentAndConfirm(secondimport);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestFromSongSelectDifferentRuleset()
|
||||
{
|
||||
var firstImport = importBeatmap(1);
|
||||
presentAndConfirm(firstImport);
|
||||
|
||||
var secondimport = importBeatmap(2, new ManiaRuleset().RulesetInfo);
|
||||
presentAndConfirm(secondimport);
|
||||
}
|
||||
|
||||
private Func<BeatmapSetInfo> importBeatmap(int i, RulesetInfo ruleset = null)
|
||||
{
|
||||
BeatmapSetInfo imported = null;
|
||||
AddStep($"import beatmap {i}", () =>
|
||||
{
|
||||
var difficulty = new BeatmapDifficulty();
|
||||
var metadata = new BeatmapMetadata
|
||||
{
|
||||
Artist = "SomeArtist",
|
||||
AuthorString = "SomeAuthor",
|
||||
Title = $"import {i}"
|
||||
};
|
||||
|
||||
imported = Game.BeatmapManager.Import(new BeatmapSetInfo
|
||||
{
|
||||
Hash = Guid.NewGuid().ToString(),
|
||||
OnlineBeatmapSetID = i,
|
||||
Metadata = metadata,
|
||||
Beatmaps = new List<BeatmapInfo>
|
||||
{
|
||||
new BeatmapInfo
|
||||
{
|
||||
OnlineBeatmapID = i * 1024,
|
||||
Metadata = metadata,
|
||||
BaseDifficulty = difficulty,
|
||||
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
||||
},
|
||||
}
|
||||
}).Result;
|
||||
});
|
||||
|
||||
AddAssert($"import {i} succeeded", () => imported != null);
|
||||
|
||||
return () => imported;
|
||||
}
|
||||
|
||||
private void presentAndConfirm(Func<BeatmapSetInfo> getImport)
|
||||
{
|
||||
AddStep("present beatmap", () => Game.PresentBeatmap(getImport()));
|
||||
|
||||
AddUntilStep("wait for song select", () => Game.ScreenStack.CurrentScreen is Screens.Select.SongSelect);
|
||||
AddUntilStep("correct beatmap displayed", () => Game.Beatmap.Value.BeatmapSetInfo.ID == getImport().ID);
|
||||
AddAssert("correct ruleset selected", () => Game.Ruleset.Value.ID == getImport().Beatmaps.First().Ruleset.ID);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,78 +6,26 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Mods;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Menu;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Select;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
using IntroSequence = osu.Game.Configuration.IntroSequence;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Menus
|
||||
namespace osu.Game.Tests.Visual.Navigation
|
||||
{
|
||||
public class TestSceneScreenNavigation : ManualInputManagerTestScene
|
||||
public class TestSceneScreenNavigation : OsuGameTestScene
|
||||
{
|
||||
private const float click_padding = 25;
|
||||
|
||||
private GameHost host;
|
||||
private TestOsuGame game;
|
||||
private Vector2 backButtonPosition => Game.ToScreenSpace(new Vector2(click_padding, Game.LayoutRectangle.Bottom - click_padding));
|
||||
|
||||
private Vector2 backButtonPosition => game.ToScreenSpace(new Vector2(click_padding, game.LayoutRectangle.Bottom - click_padding));
|
||||
|
||||
private Vector2 optionsButtonPosition => game.ToScreenSpace(new Vector2(click_padding, click_padding));
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host)
|
||||
{
|
||||
this.host = host;
|
||||
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
};
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("Create new game instance", () =>
|
||||
{
|
||||
if (game != null)
|
||||
{
|
||||
Remove(game);
|
||||
game.Dispose();
|
||||
}
|
||||
|
||||
game = new TestOsuGame(LocalStorage, API);
|
||||
game.SetHost(host);
|
||||
|
||||
// todo: this can be removed once we can run audio trakcs without a device present
|
||||
// see https://github.com/ppy/osu/issues/1302
|
||||
game.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles);
|
||||
|
||||
Add(game);
|
||||
});
|
||||
AddUntilStep("Wait for load", () => game.IsLoaded);
|
||||
AddUntilStep("Wait for intro", () => game.ScreenStack.CurrentScreen is IntroScreen);
|
||||
confirmAtMainMenu();
|
||||
}
|
||||
private Vector2 optionsButtonPosition => Game.ToScreenSpace(new Vector2(click_padding, click_padding));
|
||||
|
||||
[Test]
|
||||
public void TestExitSongSelectWithEscape()
|
||||
@ -98,21 +46,21 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
{
|
||||
Player player = null;
|
||||
|
||||
WorkingBeatmap beatmap() => game.Beatmap.Value;
|
||||
WorkingBeatmap beatmap() => Game.Beatmap.Value;
|
||||
Track track() => beatmap().Track;
|
||||
|
||||
pushAndConfirm(() => new TestSongSelect());
|
||||
|
||||
AddStep("import beatmap", () => ImportBeatmapTest.LoadOszIntoOsu(game, virtualTrack: true).Wait());
|
||||
AddStep("import beatmap", () => ImportBeatmapTest.LoadOszIntoOsu(Game, virtualTrack: true).Wait());
|
||||
|
||||
AddUntilStep("wait for selected", () => !game.Beatmap.IsDefault);
|
||||
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
|
||||
|
||||
if (withUserPause)
|
||||
AddStep("pause", () => game.Dependencies.Get<MusicController>().Stop());
|
||||
AddStep("pause", () => Game.Dependencies.Get<MusicController>().Stop());
|
||||
|
||||
AddStep("press enter", () => pressAndRelease(Key.Enter));
|
||||
|
||||
AddUntilStep("wait for player", () => (player = game.ScreenStack.CurrentScreen as Player) != null);
|
||||
AddUntilStep("wait for player", () => (player = Game.ScreenStack.CurrentScreen as Player) != null);
|
||||
AddUntilStep("wait for fail", () => player.HasFailed);
|
||||
|
||||
AddUntilStep("wait for track stop", () => !track().IsRunning);
|
||||
@ -135,7 +83,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(backButtonPosition));
|
||||
|
||||
// BackButton handles hover using its child button, so this checks whether or not any of BackButton's children are hovered.
|
||||
AddUntilStep("Back button is hovered", () => InputManager.HoveredDrawables.Any(d => d.Parent == game.BackButton));
|
||||
AddUntilStep("Back button is hovered", () => InputManager.HoveredDrawables.Any(d => d.Parent == Game.BackButton));
|
||||
|
||||
AddStep("Click back button", () => InputManager.Click(MouseButton.Left));
|
||||
AddUntilStep("Overlay was hidden", () => songSelect.ModSelectOverlay.State.Value == Visibility.Hidden);
|
||||
@ -159,20 +107,20 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
[Test]
|
||||
public void TestOpenOptionsAndExitWithEscape()
|
||||
{
|
||||
AddUntilStep("Wait for options to load", () => game.Settings.IsLoaded);
|
||||
AddUntilStep("Wait for options to load", () => Game.Settings.IsLoaded);
|
||||
AddStep("Enter menu", () => pressAndRelease(Key.Enter));
|
||||
AddStep("Move mouse to options overlay", () => InputManager.MoveMouseTo(optionsButtonPosition));
|
||||
AddStep("Click options overlay", () => InputManager.Click(MouseButton.Left));
|
||||
AddAssert("Options overlay was opened", () => game.Settings.State.Value == Visibility.Visible);
|
||||
AddAssert("Options overlay was opened", () => Game.Settings.State.Value == Visibility.Visible);
|
||||
AddStep("Hide options overlay using escape", () => pressAndRelease(Key.Escape));
|
||||
AddAssert("Options overlay was closed", () => game.Settings.State.Value == Visibility.Hidden);
|
||||
AddAssert("Options overlay was closed", () => Game.Settings.State.Value == Visibility.Hidden);
|
||||
}
|
||||
|
||||
private void pushAndConfirm(Func<Screen> newScreen)
|
||||
{
|
||||
Screen screen = null;
|
||||
AddStep("Push new screen", () => game.ScreenStack.Push(screen = newScreen()));
|
||||
AddUntilStep("Wait for new screen", () => game.ScreenStack.CurrentScreen == screen && screen.IsLoaded);
|
||||
AddStep("Push new screen", () => Game.ScreenStack.Push(screen = newScreen()));
|
||||
AddUntilStep("Wait for new screen", () => Game.ScreenStack.CurrentScreen == screen && screen.IsLoaded);
|
||||
}
|
||||
|
||||
private void pushEscape() =>
|
||||
@ -181,64 +129,25 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
private void exitViaEscapeAndConfirm()
|
||||
{
|
||||
pushEscape();
|
||||
confirmAtMainMenu();
|
||||
ConfirmAtMainMenu();
|
||||
}
|
||||
|
||||
private void exitViaBackButtonAndConfirm()
|
||||
{
|
||||
AddStep("Move mouse to backButton", () => InputManager.MoveMouseTo(backButtonPosition));
|
||||
AddStep("Click back button", () => InputManager.Click(MouseButton.Left));
|
||||
confirmAtMainMenu();
|
||||
ConfirmAtMainMenu();
|
||||
}
|
||||
|
||||
private void confirmAtMainMenu() => AddUntilStep("Wait for main menu", () => game.ScreenStack.CurrentScreen is MainMenu menu && menu.IsLoaded);
|
||||
|
||||
private void pressAndRelease(Key key)
|
||||
{
|
||||
InputManager.PressKey(key);
|
||||
InputManager.ReleaseKey(key);
|
||||
}
|
||||
|
||||
private class TestOsuGame : OsuGame
|
||||
{
|
||||
public new ScreenStack ScreenStack => base.ScreenStack;
|
||||
|
||||
public new BackButton BackButton => base.BackButton;
|
||||
|
||||
public new SettingsPanel Settings => base.Settings;
|
||||
|
||||
public new OsuConfigManager LocalConfig => base.LocalConfig;
|
||||
|
||||
public new Bindable<WorkingBeatmap> Beatmap => base.Beatmap;
|
||||
|
||||
protected override Loader CreateLoader() => new TestLoader();
|
||||
|
||||
public TestOsuGame(Storage storage, IAPIProvider api)
|
||||
{
|
||||
Storage = storage;
|
||||
API = api;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
API.Login("Rhythm Champion", "osu!");
|
||||
}
|
||||
}
|
||||
|
||||
private class TestSongSelect : PlaySongSelect
|
||||
{
|
||||
public ModSelectOverlay ModSelectOverlay => ModSelect;
|
||||
}
|
||||
|
||||
private class TestLoader : Loader
|
||||
{
|
||||
protected override ShaderPrecompiler CreateShaderPrecompiler() => new TestShaderPrecompiler();
|
||||
|
||||
private class TestShaderPrecompiler : ShaderPrecompiler
|
||||
{
|
||||
protected override bool AllLoaded => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -118,6 +118,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
InputManager.ReleaseKey(Key.Enter);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
|
||||
AddAssert("ensure selection changed", () => selected != Beatmap.Value);
|
||||
|
||||
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());
|
||||
@ -145,6 +146,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
InputManager.ReleaseKey(Key.Down);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
|
||||
AddAssert("ensure selection didn't change", () => selected == Beatmap.Value);
|
||||
|
||||
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());
|
||||
@ -176,6 +178,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
InputManager.ReleaseKey(Key.Enter);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
|
||||
AddAssert("ensure selection changed", () => selected != Beatmap.Value);
|
||||
|
||||
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());
|
||||
@ -208,6 +211,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
InputManager.ReleaseButton(MouseButton.Left);
|
||||
});
|
||||
|
||||
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
|
||||
AddAssert("ensure selection didn't change", () => selected == Beatmap.Value);
|
||||
|
||||
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());
|
||||
|
@ -36,6 +36,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public virtual string TooltipText { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to format the tooltip as a percentage or the actual value.
|
||||
/// </summary>
|
||||
public bool DisplayAsPercentage { get; set; }
|
||||
|
||||
private Color4 accentColour;
|
||||
|
||||
public Color4 AccentColour
|
||||
@ -169,11 +174,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
else
|
||||
{
|
||||
double floatValue = value.ToDouble(NumberFormatInfo.InvariantInfo);
|
||||
double floatMinValue = CurrentNumber.MinValue.ToDouble(NumberFormatInfo.InvariantInfo);
|
||||
double floatMaxValue = CurrentNumber.MaxValue.ToDouble(NumberFormatInfo.InvariantInfo);
|
||||
|
||||
if (floatMaxValue == 1 && floatMinValue >= -1)
|
||||
if (DisplayAsPercentage)
|
||||
{
|
||||
TooltipText = floatValue.ToString("P0");
|
||||
}
|
||||
else
|
||||
{
|
||||
var decimalPrecision = normalise(CurrentNumber.Precision.ToDecimal(NumberFormatInfo.InvariantInfo), max_decimal_digits);
|
||||
|
@ -17,10 +17,34 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SettingsSlider<double> { LabelText = "Master", Bindable = audio.Volume, KeyboardStep = 0.01f },
|
||||
new SettingsSlider<double> { LabelText = "Master (window inactive)", Bindable = config.GetBindable<double>(OsuSetting.VolumeInactive), KeyboardStep = 0.01f },
|
||||
new SettingsSlider<double> { LabelText = "Effect", Bindable = audio.VolumeSample, KeyboardStep = 0.01f },
|
||||
new SettingsSlider<double> { LabelText = "Music", Bindable = audio.VolumeTrack, KeyboardStep = 0.01f },
|
||||
new SettingsSlider<double>
|
||||
{
|
||||
LabelText = "Master",
|
||||
Bindable = audio.Volume,
|
||||
KeyboardStep = 0.01f,
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
new SettingsSlider<double>
|
||||
{
|
||||
LabelText = "Master (window inactive)",
|
||||
Bindable = config.GetBindable<double>(OsuSetting.VolumeInactive),
|
||||
KeyboardStep = 0.01f,
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
new SettingsSlider<double>
|
||||
{
|
||||
LabelText = "Effect",
|
||||
Bindable = audio.VolumeSample,
|
||||
KeyboardStep = 0.01f,
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
new SettingsSlider<double>
|
||||
{
|
||||
LabelText = "Music",
|
||||
Bindable = audio.VolumeTrack,
|
||||
KeyboardStep = 0.01f,
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -21,13 +21,15 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
{
|
||||
LabelText = "Background dim",
|
||||
Bindable = config.GetBindable<double>(OsuSetting.DimLevel),
|
||||
KeyboardStep = 0.01f
|
||||
KeyboardStep = 0.01f,
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
new SettingsSlider<double>
|
||||
{
|
||||
LabelText = "Background blur",
|
||||
Bindable = config.GetBindable<double>(OsuSetting.BlurLevel),
|
||||
KeyboardStep = 0.01f
|
||||
KeyboardStep = 0.01f,
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
new SettingsCheckbox
|
||||
{
|
||||
|
@ -98,25 +98,29 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
|
||||
{
|
||||
LabelText = "Horizontal position",
|
||||
Bindable = scalingPositionX,
|
||||
KeyboardStep = 0.01f
|
||||
KeyboardStep = 0.01f,
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
LabelText = "Vertical position",
|
||||
Bindable = scalingPositionY,
|
||||
KeyboardStep = 0.01f
|
||||
KeyboardStep = 0.01f,
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
LabelText = "Horizontal scale",
|
||||
Bindable = scalingSizeX,
|
||||
KeyboardStep = 0.01f
|
||||
KeyboardStep = 0.01f,
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
new SettingsSlider<float>
|
||||
{
|
||||
LabelText = "Vertical scale",
|
||||
Bindable = scalingSizeY,
|
||||
KeyboardStep = 0.01f
|
||||
KeyboardStep = 0.01f,
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Overlays.Settings
|
||||
@ -22,16 +23,32 @@ namespace osu.Game.Overlays.Settings
|
||||
RelativeSizeAxes = Axes.X
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// When set, value changes based on user input are only transferred to any bound control's Current on commit.
|
||||
/// This is useful if the UI interaction could be adversely affected by the value changing, such as the position of the <see cref="SliderBar{T}"/> on the screen.
|
||||
/// </summary>
|
||||
public bool TransferValueOnCommit
|
||||
{
|
||||
get => ((TSlider)Control).TransferValueOnCommit;
|
||||
set => ((TSlider)Control).TransferValueOnCommit = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A custom step value for each key press which actuates a change on this control.
|
||||
/// </summary>
|
||||
public float KeyboardStep
|
||||
{
|
||||
get => ((TSlider)Control).KeyboardStep;
|
||||
set => ((TSlider)Control).KeyboardStep = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether to format the tooltip as a percentage or the actual value.
|
||||
/// </summary>
|
||||
public bool DisplayAsPercentage
|
||||
{
|
||||
get => ((TSlider)Control).DisplayAsPercentage;
|
||||
set => ((TSlider)Control).DisplayAsPercentage = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Timing;
|
||||
@ -25,6 +26,7 @@ using osu.Game.Screens.Edit.Components.RadioButtons;
|
||||
using osu.Game.Screens.Edit.Compose;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
using osuTK;
|
||||
using Key = osuTK.Input.Key;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
@ -58,6 +60,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
private InputManager inputManager;
|
||||
|
||||
private RadioButtonCollection toolboxCollection;
|
||||
|
||||
protected HitObjectComposer(Ruleset ruleset)
|
||||
{
|
||||
Ruleset = ruleset;
|
||||
@ -100,7 +104,6 @@ namespace osu.Game.Rulesets.Edit
|
||||
layerContainers.Add(layerBelowRuleset);
|
||||
layerContainers.Add(layerAboveRuleset);
|
||||
|
||||
RadioButtonCollection toolboxCollection;
|
||||
InternalChild = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -137,16 +140,32 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
};
|
||||
|
||||
toolboxCollection.Items =
|
||||
CompositionTools.Select(t => new RadioButton(t.Name, () => selectTool(t)))
|
||||
.Prepend(new RadioButton("Select", () => selectTool(null)))
|
||||
.ToList();
|
||||
toolboxCollection.Items = CompositionTools
|
||||
.Prepend(new SelectTool())
|
||||
.Select(t => new RadioButton(t.Name, () => toolSelected(t)))
|
||||
.ToList();
|
||||
|
||||
toolboxCollection.Items[0].Select();
|
||||
setSelectTool();
|
||||
|
||||
blueprintContainer.SelectionChanged += selectionChanged;
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
if (e.Key >= Key.Number1 && e.Key <= Key.Number9)
|
||||
{
|
||||
var item = toolboxCollection.Items.Skip(e.Key - Key.Number1).FirstOrDefault();
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
item.Select();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -181,20 +200,30 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
var hitObjects = selectedHitObjects.ToArray();
|
||||
|
||||
if (!hitObjects.Any())
|
||||
distanceSnapGridContainer.Hide();
|
||||
else
|
||||
if (hitObjects.Any())
|
||||
{
|
||||
// ensure in selection mode if a selection is made.
|
||||
setSelectTool();
|
||||
|
||||
showGridFor(hitObjects);
|
||||
}
|
||||
else
|
||||
distanceSnapGridContainer.Hide();
|
||||
}
|
||||
|
||||
private void selectTool(HitObjectCompositionTool tool)
|
||||
private void setSelectTool() => toolboxCollection.Items.First().Select();
|
||||
|
||||
private void toolSelected(HitObjectCompositionTool tool)
|
||||
{
|
||||
blueprintContainer.CurrentTool = tool;
|
||||
|
||||
if (tool == null)
|
||||
if (tool is SelectTool)
|
||||
distanceSnapGridContainer.Hide();
|
||||
else
|
||||
{
|
||||
EditorBeatmap.SelectedHitObjects.Clear();
|
||||
showGridFor(Enumerable.Empty<HitObject>());
|
||||
}
|
||||
}
|
||||
|
||||
private void showGridFor(IEnumerable<HitObject> selectedHitObjects)
|
||||
@ -275,10 +304,10 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
|
||||
public override double GetSnappedDurationFromDistance(double referenceTime, float distance)
|
||||
=> beatSnapProvider.SnapTime(referenceTime, DistanceToDuration(referenceTime, distance));
|
||||
=> beatSnapProvider.SnapTime(referenceTime + DistanceToDuration(referenceTime, distance), referenceTime) - referenceTime;
|
||||
|
||||
public override float GetSnappedDistanceFromDistance(double referenceTime, float distance)
|
||||
=> DurationToDistance(referenceTime, beatSnapProvider.SnapTime(referenceTime, DistanceToDuration(referenceTime, distance)));
|
||||
=> DurationToDistance(referenceTime, beatSnapProvider.SnapTime(DistanceToDuration(referenceTime, distance), referenceTime));
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
|
@ -8,10 +8,10 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <summary>
|
||||
/// Snaps a duration to the closest beat of a timing point applicable at the reference time.
|
||||
/// </summary>
|
||||
/// <param name="referenceTime">The time of the timing point which <paramref name="duration"/> resides in.</param>
|
||||
/// <param name="duration">The duration to snap.</param>
|
||||
/// <returns>A value that represents <paramref name="duration"/> snapped to the closest beat of the timing point.</returns>
|
||||
double SnapTime(double referenceTime, double duration);
|
||||
/// <param name="time">The time to snap.</param>
|
||||
/// <param name="referenceTime">An optional reference point to use for timing point lookup.</param>
|
||||
/// <returns>A value that represents <paramref name="time"/> snapped to the closest beat of the timing point.</returns>
|
||||
double SnapTime(double time, double? referenceTime = null);
|
||||
|
||||
/// <summary>
|
||||
/// Get the most appropriate beat length at a given time.
|
||||
|
@ -13,5 +13,7 @@ namespace osu.Game.Rulesets.Edit.Tools
|
||||
}
|
||||
|
||||
public abstract PlacementBlueprint CreatePlacementBlueprint();
|
||||
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
}
|
||||
|
15
osu.Game/Rulesets/Edit/Tools/SelectTool.cs
Normal file
15
osu.Game/Rulesets/Edit/Tools/SelectTool.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Tools
|
||||
{
|
||||
public class SelectTool : HitObjectCompositionTool
|
||||
{
|
||||
public SelectTool()
|
||||
: base("Select")
|
||||
{
|
||||
}
|
||||
|
||||
public override PlacementBlueprint CreatePlacementBlueprint() => null;
|
||||
}
|
||||
}
|
@ -52,30 +52,52 @@ namespace osu.Game.Screens.Edit
|
||||
{
|
||||
switch (beatDivisor)
|
||||
{
|
||||
case 1:
|
||||
return Color4.White;
|
||||
|
||||
case 2:
|
||||
return colours.BlueLight;
|
||||
return colours.Red;
|
||||
|
||||
case 4:
|
||||
return colours.Blue;
|
||||
|
||||
case 8:
|
||||
return colours.BlueDarker;
|
||||
return colours.Yellow;
|
||||
|
||||
case 16:
|
||||
return colours.PurpleDark;
|
||||
|
||||
case 3:
|
||||
return colours.YellowLight;
|
||||
return colours.Purple;
|
||||
|
||||
case 6:
|
||||
return colours.Yellow;
|
||||
return colours.YellowDark;
|
||||
|
||||
case 12:
|
||||
return colours.YellowDarker;
|
||||
|
||||
default:
|
||||
return Color4.White;
|
||||
return Color4.Red;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the applicable divisor for a specific beat index.
|
||||
/// </summary>
|
||||
/// <param name="index">The 0-based beat index.</param>
|
||||
/// <param name="beatDivisor">The beat divisor.</param>
|
||||
/// <returns>The applicable divisor.</returns>
|
||||
public static int GetDivisorForBeatIndex(int index, int beatDivisor)
|
||||
{
|
||||
int beat = index % beatDivisor;
|
||||
|
||||
foreach (var divisor in BindableBeatDivisor.VALID_DIVISORS)
|
||||
{
|
||||
if ((beat * divisor) % beatDivisor == 0)
|
||||
return divisor;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -37,8 +36,8 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
|
||||
{
|
||||
this.button = button;
|
||||
|
||||
Text = button.Text;
|
||||
Action = button.Action;
|
||||
Text = button.Item.ToString();
|
||||
Action = button.Select;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
@ -100,19 +99,6 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
|
||||
bubble.Colour = button.Selected.Value ? selectedBubbleColour : defaultBubbleColour;
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (button.Selected.Value)
|
||||
return true;
|
||||
|
||||
if (!Enabled.Value)
|
||||
return true;
|
||||
|
||||
button.Selected.Value = true;
|
||||
|
||||
return base.OnClick(e);
|
||||
}
|
||||
|
||||
protected override SpriteText CreateText() => new OsuSpriteText
|
||||
{
|
||||
Depth = -1,
|
||||
|
@ -15,33 +15,37 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
|
||||
public readonly BindableBool Selected;
|
||||
|
||||
/// <summary>
|
||||
/// The text that should be displayed in this button.
|
||||
/// The item related to this button.
|
||||
/// </summary>
|
||||
public string Text;
|
||||
public object Item;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Action"/> that should be invoked when this button is selected.
|
||||
/// </summary>
|
||||
public Action Action;
|
||||
private readonly Action action;
|
||||
|
||||
public RadioButton(string text, Action action)
|
||||
public RadioButton(object item, Action action)
|
||||
{
|
||||
Text = text;
|
||||
Action = action;
|
||||
Item = item;
|
||||
this.action = action;
|
||||
Selected = new BindableBool();
|
||||
}
|
||||
|
||||
public RadioButton(string text)
|
||||
: this(text, null)
|
||||
public RadioButton(string item)
|
||||
: this(item, null)
|
||||
{
|
||||
Text = text;
|
||||
Action = null;
|
||||
Item = item;
|
||||
action = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Selects this <see cref="RadioButton"/>.
|
||||
/// </summary>
|
||||
public void Select() => Selected.Value = true;
|
||||
public void Select()
|
||||
{
|
||||
if (!Selected.Value)
|
||||
{
|
||||
Selected.Value = true;
|
||||
action?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deselects this <see cref="RadioButton"/>.
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations
|
||||
/// </summary>
|
||||
public class PointVisualisation : Box
|
||||
{
|
||||
protected PointVisualisation(double startTime)
|
||||
public PointVisualisation(double startTime)
|
||||
{
|
||||
Origin = Anchor.TopCentre;
|
||||
|
||||
|
@ -74,12 +74,16 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
foreach (var o in objects)
|
||||
selectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Select();
|
||||
|
||||
SelectionChanged?.Invoke(selectedHitObjects);
|
||||
};
|
||||
|
||||
selectedHitObjects.ItemsRemoved += objects =>
|
||||
{
|
||||
foreach (var o in objects)
|
||||
selectionBlueprints.FirstOrDefault(b => b.HitObject == o)?.Deselect();
|
||||
|
||||
SelectionChanged?.Invoke(selectedHitObjects);
|
||||
};
|
||||
}
|
||||
|
||||
@ -332,8 +336,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
selectionHandler.HandleSelected(blueprint);
|
||||
selectionBlueprints.ChangeChildDepth(blueprint, 1);
|
||||
beatmap.SelectedHitObjects.Add(blueprint.HitObject);
|
||||
|
||||
SelectionChanged?.Invoke(selectionHandler.SelectedHitObjects);
|
||||
}
|
||||
|
||||
private void onBlueprintDeselected(SelectionBlueprint blueprint)
|
||||
@ -341,8 +343,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
selectionHandler.HandleDeselected(blueprint);
|
||||
selectionBlueprints.ChangeChildDepth(blueprint, 0);
|
||||
beatmap.SelectedHitObjects.Remove(blueprint.HitObject);
|
||||
|
||||
SelectionChanged?.Invoke(selectionHandler.SelectedHitObjects);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CreateContent(Vector2 startPosition)
|
||||
protected override void CreateContent()
|
||||
{
|
||||
const float crosshair_thickness = 1;
|
||||
const float crosshair_max_size = 10;
|
||||
@ -26,7 +26,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
new Box
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Position = startPosition,
|
||||
Position = StartPosition,
|
||||
Width = crosshair_thickness,
|
||||
EdgeSmoothness = new Vector2(1),
|
||||
Height = Math.Min(crosshair_max_size, DistanceSpacing * 2),
|
||||
@ -34,15 +34,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
new Box
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Position = startPosition,
|
||||
Position = StartPosition,
|
||||
EdgeSmoothness = new Vector2(1),
|
||||
Width = Math.Min(crosshair_max_size, DistanceSpacing * 2),
|
||||
Height = crosshair_thickness,
|
||||
}
|
||||
});
|
||||
|
||||
float dx = Math.Max(startPosition.X, DrawWidth - startPosition.X);
|
||||
float dy = Math.Max(startPosition.Y, DrawHeight - startPosition.Y);
|
||||
float dx = Math.Max(StartPosition.X, DrawWidth - StartPosition.X);
|
||||
float dy = Math.Max(StartPosition.Y, DrawHeight - StartPosition.Y);
|
||||
float maxDistance = new Vector2(dx, dy).Length;
|
||||
int requiredCircles = Math.Min(MaxIntervals, (int)(maxDistance / DistanceSpacing));
|
||||
|
||||
@ -53,11 +53,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
AddInternal(new CircularProgress
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Position = startPosition,
|
||||
Position = StartPosition,
|
||||
Current = { Value = 1 },
|
||||
Size = new Vector2(radius),
|
||||
InnerRadius = 4 * 1f / radius,
|
||||
Colour = GetColourForBeatIndex(i)
|
||||
Colour = GetColourForIndexFromPlacement(i)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
@ -106,7 +107,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
if (!gridCache.IsValid)
|
||||
{
|
||||
ClearInternal();
|
||||
CreateContent(StartPosition);
|
||||
CreateContent();
|
||||
gridCache.Validate();
|
||||
}
|
||||
}
|
||||
@ -114,7 +115,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <summary>
|
||||
/// Creates the content which visualises the grid ticks.
|
||||
/// </summary>
|
||||
protected abstract void CreateContent(Vector2 startPosition);
|
||||
protected abstract void CreateContent();
|
||||
|
||||
/// <summary>
|
||||
/// Snaps a position to this grid.
|
||||
@ -126,25 +127,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <summary>
|
||||
/// Retrieves the applicable colour for a beat index.
|
||||
/// </summary>
|
||||
/// <param name="index">The 0-based beat index.</param>
|
||||
/// <param name="placementIndex">The 0-based beat index from the point of placement.</param>
|
||||
/// <returns>The applicable colour.</returns>
|
||||
protected ColourInfo GetColourForBeatIndex(int index)
|
||||
protected ColourInfo GetColourForIndexFromPlacement(int placementIndex)
|
||||
{
|
||||
int beat = (index + 1) % beatDivisor.Value;
|
||||
ColourInfo colour = Colours.Gray5;
|
||||
var timingPoint = beatmap.ControlPointInfo.TimingPointAt(StartTime);
|
||||
var beatLength = timingPoint.BeatLength / beatDivisor.Value;
|
||||
var beatIndex = (int)Math.Round((StartTime - timingPoint.Time) / beatLength);
|
||||
|
||||
for (int i = 0; i < BindableBeatDivisor.VALID_DIVISORS.Length; i++)
|
||||
{
|
||||
int divisor = BindableBeatDivisor.VALID_DIVISORS[i];
|
||||
var colour = BindableBeatDivisor.GetColourFor(BindableBeatDivisor.GetDivisorForBeatIndex(beatIndex + placementIndex + 1, beatDivisor.Value), Colours);
|
||||
|
||||
if ((beat * divisor) % beatDivisor.Value == 0)
|
||||
{
|
||||
colour = BindableBeatDivisor.GetColourFor(divisor, Colours);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int repeatIndex = index / beatDivisor.Value;
|
||||
int repeatIndex = placementIndex / beatDivisor.Value;
|
||||
return colour.MultiplyAlpha(0.5f / (repeatIndex + 1));
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
ZoomDuration = 200;
|
||||
ZoomEasing = Easing.OutQuint;
|
||||
Zoom = 10;
|
||||
ScrollbarVisible = false;
|
||||
}
|
||||
|
||||
@ -61,9 +60,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
waveform.Waveform = b.NewValue.Waveform;
|
||||
track = b.NewValue.Track;
|
||||
|
||||
MinZoom = getZoomLevelForVisibleMilliseconds(10000);
|
||||
MaxZoom = getZoomLevelForVisibleMilliseconds(500);
|
||||
Zoom = getZoomLevelForVisibleMilliseconds(2000);
|
||||
}, true);
|
||||
}
|
||||
|
||||
private float getZoomLevelForVisibleMilliseconds(double milliseconds) => (float)(track.Length / milliseconds);
|
||||
|
||||
/// <summary>
|
||||
/// The timeline's scroll position in the last frame.
|
||||
/// </summary>
|
||||
@ -177,7 +182,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
public (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time)
|
||||
{
|
||||
var targetTime = (position.X / Content.DrawWidth) * track.Length;
|
||||
return (position, beatSnapProvider.SnapTime(targetTime, targetTime));
|
||||
return (position, beatSnapProvider.SnapTime(targetTime));
|
||||
}
|
||||
|
||||
public float GetBeatSnapDistanceAt(double referenceTime) => throw new NotImplementedException();
|
||||
|
@ -0,0 +1,90 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
public class TimelineTickDisplay : TimelinePart
|
||||
{
|
||||
[Resolved]
|
||||
private EditorBeatmap beatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<WorkingBeatmap> working { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private BindableBeatDivisor beatDivisor { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
public TimelineTickDisplay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
beatDivisor.BindValueChanged(_ => createLines(), true);
|
||||
}
|
||||
|
||||
private void createLines()
|
||||
{
|
||||
Clear();
|
||||
|
||||
for (var i = 0; i < beatmap.ControlPointInfo.TimingPoints.Count; i++)
|
||||
{
|
||||
var point = beatmap.ControlPointInfo.TimingPoints[i];
|
||||
var until = beatmap.ControlPointInfo.TimingPoints.Count < i + 1 ? beatmap.ControlPointInfo.TimingPoints[i + 1].Time : working.Value.Track.Length;
|
||||
|
||||
int beat = 0;
|
||||
|
||||
for (double t = point.Time; t < until; t += point.BeatLength / beatDivisor.Value)
|
||||
{
|
||||
var indexInBeat = beat % beatDivisor.Value;
|
||||
|
||||
if (indexInBeat == 0)
|
||||
{
|
||||
Add(new PointVisualisation(t)
|
||||
{
|
||||
Colour = BindableBeatDivisor.GetColourFor(1, colours),
|
||||
Origin = Anchor.TopCentre,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var divisor = BindableBeatDivisor.GetDivisorForBeatIndex(beat, beatDivisor.Value);
|
||||
var colour = BindableBeatDivisor.GetColourFor(divisor, colours);
|
||||
var height = 0.1f - (float)divisor / BindableBeatDivisor.VALID_DIVISORS.Last() * 0.08f;
|
||||
|
||||
Add(new PointVisualisation(t)
|
||||
{
|
||||
Colour = colour,
|
||||
Height = height,
|
||||
Origin = Anchor.TopCentre,
|
||||
});
|
||||
|
||||
Add(new PointVisualisation(t)
|
||||
{
|
||||
Colour = colour,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Height = height,
|
||||
});
|
||||
}
|
||||
|
||||
beat++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -36,12 +36,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
base.Content.Add(zoomedContent = new Container { RelativeSizeAxes = Axes.Y });
|
||||
}
|
||||
|
||||
private int minZoom = 1;
|
||||
private float minZoom = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum zoom level allowed.
|
||||
/// </summary>
|
||||
public int MinZoom
|
||||
public float MinZoom
|
||||
{
|
||||
get => minZoom;
|
||||
set
|
||||
@ -56,12 +56,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
}
|
||||
}
|
||||
|
||||
private int maxZoom = 60;
|
||||
private float maxZoom = 60;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum zoom level allowed.
|
||||
/// </summary>
|
||||
public int MaxZoom
|
||||
public float MaxZoom
|
||||
{
|
||||
get => maxZoom;
|
||||
set
|
||||
|
@ -348,7 +348,7 @@ namespace osu.Game.Screens.Edit
|
||||
beatmapManager.Export(Beatmap.Value.BeatmapSetInfo);
|
||||
}
|
||||
|
||||
public double SnapTime(double referenceTime, double duration) => editorBeatmap.SnapTime(referenceTime, duration);
|
||||
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);
|
||||
|
||||
public double GetBeatLengthAtTime(double referenceTime) => editorBeatmap.GetBeatLengthAtTime(referenceTime);
|
||||
|
||||
|
@ -128,12 +128,12 @@ namespace osu.Game.Screens.Edit
|
||||
return list.Count - 1;
|
||||
}
|
||||
|
||||
public double SnapTime(double referenceTime, double duration)
|
||||
public double SnapTime(double time, double? referenceTime)
|
||||
{
|
||||
double beatLength = GetBeatLengthAtTime(referenceTime);
|
||||
var timingPoint = ControlPointInfo.TimingPointAt(referenceTime ?? time);
|
||||
var beatLength = timingPoint.BeatLength / BeatDivisor;
|
||||
|
||||
// A 1ms offset prevents rounding errors due to minute variations in duration
|
||||
return (int)((duration + 1) / beatLength) * beatLength;
|
||||
return timingPoint.Time + (int)Math.Round((time - timingPoint.Time) / beatLength, MidpointRounding.AwayFromZero) * beatLength;
|
||||
}
|
||||
|
||||
public double GetBeatLengthAtTime(double referenceTime) => ControlPointInfo.TimingPointAt(referenceTime).BeatLength / BeatDivisor;
|
||||
|
@ -102,7 +102,11 @@ namespace osu.Game.Screens.Edit
|
||||
LoadComponentAsync(new TimelineArea
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = CreateTimelineContent()
|
||||
Children = new[]
|
||||
{
|
||||
new TimelineTickDisplay(),
|
||||
CreateTimelineContent(),
|
||||
}
|
||||
}, timelineContainer.Add);
|
||||
});
|
||||
}
|
||||
|
@ -27,12 +27,18 @@ namespace osu.Game.Screens.Play.PlayerSettings
|
||||
{
|
||||
Text = "Background dim:"
|
||||
},
|
||||
dimSliderBar = new PlayerSliderBar<double>(),
|
||||
dimSliderBar = new PlayerSliderBar<double>
|
||||
{
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "Background blur:"
|
||||
},
|
||||
blurSliderBar = new PlayerSliderBar<double>(),
|
||||
blurSliderBar = new PlayerSliderBar<double>
|
||||
{
|
||||
DisplayAsPercentage = true
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "Toggles:"
|
||||
|
@ -68,6 +68,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Children.OfType<CarouselBeatmapSet>();
|
||||
|
||||
// todo: only used for testing, maybe remove.
|
||||
public IEnumerable<BeatmapSetInfo> BeatmapSets
|
||||
{
|
||||
get => beatmapSets.Select(g => g.BeatmapSet);
|
||||
@ -133,8 +134,11 @@ namespace osu.Game.Screens.Select
|
||||
};
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(OsuConfigManager config, BeatmapManager beatmaps)
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
config.BindWith(OsuSetting.RandomSelectAlgorithm, RandomAlgorithm);
|
||||
config.BindWith(OsuSetting.SongSelectRightMouseScroll, RightClickScrollingEnabled);
|
||||
@ -142,6 +146,11 @@ namespace osu.Game.Screens.Select
|
||||
RightClickScrollingEnabled.ValueChanged += enabled => scroll.RightMouseScrollbar = enabled.NewValue;
|
||||
RightClickScrollingEnabled.TriggerChange();
|
||||
|
||||
beatmaps.ItemAdded += beatmapAdded;
|
||||
beatmaps.ItemRemoved += beatmapRemoved;
|
||||
beatmaps.BeatmapHidden += beatmapHidden;
|
||||
beatmaps.BeatmapRestored += beatmapRestored;
|
||||
|
||||
loadBeatmapSets(beatmaps.GetAllUsableBeatmapSetsEnumerable());
|
||||
}
|
||||
|
||||
@ -535,11 +544,27 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (beatmaps != null)
|
||||
{
|
||||
beatmaps.ItemAdded -= beatmapAdded;
|
||||
beatmaps.ItemRemoved -= beatmapRemoved;
|
||||
beatmaps.BeatmapHidden -= beatmapHidden;
|
||||
beatmaps.BeatmapRestored -= beatmapRestored;
|
||||
}
|
||||
|
||||
// aggressively dispose "off-screen" items to reduce GC pressure.
|
||||
foreach (var i in Items)
|
||||
i.Dispose();
|
||||
}
|
||||
|
||||
private void beatmapRemoved(BeatmapSetInfo item) => RemoveBeatmapSet(item);
|
||||
|
||||
private void beatmapAdded(BeatmapSetInfo item) => UpdateBeatmapSet(item);
|
||||
|
||||
private void beatmapRestored(BeatmapInfo b) => UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||
|
||||
private void beatmapHidden(BeatmapInfo b) => UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||
|
||||
private CarouselBeatmapSet createCarouselSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
if (beatmapSet.Beatmaps.All(b => b.Hidden))
|
||||
|
@ -117,9 +117,20 @@ namespace osu.Game.Screens.Select.Details
|
||||
mod.ApplyToDifficulty(adjustedDifficulty);
|
||||
}
|
||||
|
||||
// Account for mania differences
|
||||
firstValue.Title = (Beatmap?.Ruleset?.ID ?? 0) == 3 ? "Key Amount" : "Circle Size";
|
||||
firstValue.Value = (baseDifficulty?.CircleSize ?? 0, adjustedDifficulty?.CircleSize);
|
||||
switch (Beatmap?.Ruleset?.ID ?? 0)
|
||||
{
|
||||
case 3:
|
||||
// Account for mania differences locally for now
|
||||
// Eventually this should be handled in a more modular way, allowing rulesets to return arbitrary difficulty attributes
|
||||
firstValue.Title = "Key Count";
|
||||
firstValue.Value = (baseDifficulty?.CircleSize ?? 0, null);
|
||||
break;
|
||||
|
||||
default:
|
||||
firstValue.Title = "Circle Size";
|
||||
firstValue.Value = (baseDifficulty?.CircleSize ?? 0, adjustedDifficulty?.CircleSize);
|
||||
break;
|
||||
}
|
||||
|
||||
starDifficulty.Value = ((float)(Beatmap?.StarDifficulty ?? 0), null);
|
||||
|
||||
|
@ -72,7 +72,9 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
private BeatmapInfoWedge beatmapInfoWedge;
|
||||
private DialogOverlay dialogOverlay;
|
||||
private BeatmapManager beatmaps;
|
||||
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; }
|
||||
|
||||
protected ModSelectOverlay ModSelect { get; private set; }
|
||||
|
||||
@ -89,7 +91,7 @@ namespace osu.Game.Screens.Select
|
||||
private MusicController music { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins, ScoreManager scores)
|
||||
private void load(AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins, ScoreManager scores)
|
||||
{
|
||||
// initial value transfer is required for FilterControl (it uses our re-cached bindables in its async load for the initial filter).
|
||||
transferRulesetValue();
|
||||
@ -247,14 +249,6 @@ namespace osu.Game.Screens.Select
|
||||
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number3);
|
||||
}
|
||||
|
||||
if (this.beatmaps == null)
|
||||
this.beatmaps = beatmaps;
|
||||
|
||||
this.beatmaps.ItemAdded += onBeatmapSetAdded;
|
||||
this.beatmaps.ItemRemoved += onBeatmapSetRemoved;
|
||||
this.beatmaps.BeatmapHidden += onBeatmapHidden;
|
||||
this.beatmaps.BeatmapRestored += onBeatmapRestored;
|
||||
|
||||
dialogOverlay = dialog;
|
||||
|
||||
sampleChangeDifficulty = audio.Samples.Get(@"SongSelect/select-difficulty");
|
||||
@ -563,14 +557,6 @@ namespace osu.Game.Screens.Select
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
decoupledRuleset.UnbindAll();
|
||||
|
||||
if (beatmaps != null)
|
||||
{
|
||||
beatmaps.ItemAdded -= onBeatmapSetAdded;
|
||||
beatmaps.ItemRemoved -= onBeatmapSetRemoved;
|
||||
beatmaps.BeatmapHidden -= onBeatmapHidden;
|
||||
beatmaps.BeatmapRestored -= onBeatmapRestored;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -617,11 +603,6 @@ namespace osu.Game.Screens.Select
|
||||
lastTrack.SetTarget(track);
|
||||
}
|
||||
|
||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(s);
|
||||
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s);
|
||||
private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||
private void onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
|
||||
|
||||
private void carouselBeatmapsLoaded()
|
||||
{
|
||||
bindBindables();
|
||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected new OsuScreenDependencies Dependencies { get; private set; }
|
||||
|
||||
private readonly Lazy<Storage> localStorage;
|
||||
private Lazy<Storage> localStorage;
|
||||
protected Storage LocalStorage => localStorage.Value;
|
||||
|
||||
private readonly Lazy<DatabaseContextFactory> contextFactory;
|
||||
@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected OsuTestScene()
|
||||
{
|
||||
localStorage = new Lazy<Storage>(() => new NativeStorage($"{GetType().Name}-{Guid.NewGuid()}"));
|
||||
RecycleLocalStorage();
|
||||
contextFactory = new Lazy<DatabaseContextFactory>(() =>
|
||||
{
|
||||
var factory = new DatabaseContextFactory(LocalStorage);
|
||||
@ -104,6 +104,23 @@ namespace osu.Game.Tests.Visual
|
||||
base.Content.Add(content = new DrawSizePreservingFillContainer());
|
||||
}
|
||||
|
||||
public void RecycleLocalStorage()
|
||||
{
|
||||
if (localStorage?.IsValueCreated == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
localStorage.Value.DeleteDirectory(".");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// we don't really care if this fails; it will just leave folders lying around from test runs.
|
||||
}
|
||||
}
|
||||
|
||||
localStorage = new Lazy<Storage>(() => new NativeStorage($"{GetType().Name}-{Guid.NewGuid()}"));
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
protected AudioManager Audio { get; private set; }
|
||||
|
||||
@ -131,17 +148,7 @@ namespace osu.Game.Tests.Visual
|
||||
if (contextFactory.IsValueCreated)
|
||||
contextFactory.Value.ResetDatabase();
|
||||
|
||||
if (localStorage.IsValueCreated)
|
||||
{
|
||||
try
|
||||
{
|
||||
localStorage.Value.DeleteDirectory(".");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// we don't really care if this fails; it will just leave folders lying around from test runs.
|
||||
}
|
||||
}
|
||||
RecycleLocalStorage();
|
||||
}
|
||||
|
||||
protected override ITestSceneTestRunner CreateRunner() => new OsuTestSceneTestRunner();
|
||||
|
Loading…
Reference in New Issue
Block a user