1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 22:22:54 +08:00

Merge branch 'master' into fix-profile-graph-crash

This commit is contained in:
Dean Herbert 2020-11-10 18:06:51 +09:00
commit 2e3dc6fc46
38 changed files with 254 additions and 242 deletions

50
.vscode/tasks.json vendored
View File

@ -11,9 +11,9 @@
"build",
"--no-restore",
"osu.Desktop",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
@ -26,10 +26,10 @@
"build",
"--no-restore",
"osu.Desktop",
"/p:Configuration=Release",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:Configuration=Release",
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
@ -42,9 +42,9 @@
"build",
"--no-restore",
"osu.Game.Tests",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
@ -57,10 +57,10 @@
"build",
"--no-restore",
"osu.Game.Tests",
"/p:Configuration=Release",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:Configuration=Release",
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
@ -73,9 +73,9 @@
"build",
"--no-restore",
"osu.Game.Tournament.Tests",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
@ -88,10 +88,10 @@
"build",
"--no-restore",
"osu.Game.Tournament.Tests",
"/p:Configuration=Release",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:Configuration=Release",
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
@ -104,10 +104,10 @@
"build",
"--no-restore",
"osu.Game.Benchmarks",
"/p:Configuration=Release",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:Configuration=Release",
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"

View File

@ -135,6 +135,9 @@ namespace osu.Desktop
case UserActivity.Editing edit:
return edit.Beatmap.ToString();
case UserActivity.InLobby lobby:
return lobby.Room.Name.Value;
}
return string.Empty;

View File

@ -11,9 +11,9 @@
"build",
"--no-restore",
"osu.Game.Rulesets.Catch.Tests.csproj",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
@ -26,10 +26,10 @@
"build",
"--no-restore",
"osu.Game.Rulesets.Catch.Tests.csproj",
"/p:Configuration=Release",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:Configuration=Release",
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"

View File

@ -11,9 +11,9 @@
"build",
"--no-restore",
"osu.Game.Rulesets.Mania.Tests.csproj",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
@ -26,10 +26,10 @@
"build",
"--no-restore",
"osu.Game.Rulesets.Mania.Tests.csproj",
"/p:Configuration=Release",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:Configuration=Release",
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"

View File

@ -11,9 +11,9 @@
"build",
"--no-restore",
"osu.Game.Rulesets.Osu.Tests.csproj",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
@ -26,10 +26,10 @@
"build",
"--no-restore",
"osu.Game.Rulesets.Osu.Tests.csproj",
"/p:Configuration=Release",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:Configuration=Release",
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"

View File

@ -280,8 +280,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
private void addClickStep(MouseButton button)
{
AddStep($"press {button}", () => InputManager.PressButton(button));
AddStep($"release {button}", () => InputManager.ReleaseButton(button));
AddStep($"click {button}", () => InputManager.Click(button));
}
private void assertPlaced(bool expected) => AddAssert($"slider {(expected ? "placed" : "not placed")}", () => (getSlider() != null) == expected);

View File

@ -11,9 +11,9 @@
"build",
"--no-restore",
"osu.Game.Rulesets.Taiko.Tests.csproj",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
@ -26,10 +26,10 @@
"build",
"--no-restore",
"osu.Game.Rulesets.Taiko.Tests.csproj",
"/p:Configuration=Release",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:Configuration=Release",
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"

View File

@ -41,11 +41,11 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("store time", () => time = Player.GameplayClockContainer.GameplayClock.CurrentTime);
// test seek via keyboard
AddStep("seek with right arrow key", () => press(Key.Right));
AddStep("seek with right arrow key", () => InputManager.Key(Key.Right));
AddAssert("time seeked forward", () => Player.GameplayClockContainer.GameplayClock.CurrentTime > time + 2000);
AddStep("store time", () => time = Player.GameplayClockContainer.GameplayClock.CurrentTime);
AddStep("seek with left arrow key", () => press(Key.Left));
AddStep("seek with left arrow key", () => InputManager.Key(Key.Left));
AddAssert("time seeked backward", () => Player.GameplayClockContainer.GameplayClock.CurrentTime < time);
seekToBreak(0);
@ -67,11 +67,5 @@ namespace osu.Game.Tests.Visual.Gameplay
BreakPeriod destBreak() => Beatmap.Value.Beatmap.Breaks.ElementAt(breakIndex);
}
private void press(Key key)
{
InputManager.PressKey(key);
InputManager.ReleaseKey(key);
}
}
}

View File

@ -86,7 +86,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
showOverlay();
AddStep("Up arrow", () => press(Key.Up));
AddStep("Up arrow", () => InputManager.Key(Key.Up));
AddAssert("Last button selected", () => pauseOverlay.Buttons.Last().Selected.Value);
}
@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
showOverlay();
AddStep("Down arrow", () => press(Key.Down));
AddStep("Down arrow", () => InputManager.Key(Key.Down));
AddAssert("First button selected", () => getButton(0).Selected.Value);
}
@ -110,11 +110,11 @@ namespace osu.Game.Tests.Visual.Gameplay
{
AddStep("Show overlay", () => failOverlay.Show());
AddStep("Up arrow", () => press(Key.Up));
AddStep("Up arrow", () => InputManager.Key(Key.Up));
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value);
AddStep("Up arrow", () => press(Key.Up));
AddStep("Up arrow", () => InputManager.Key(Key.Up));
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value);
AddStep("Up arrow", () => press(Key.Up));
AddStep("Up arrow", () => InputManager.Key(Key.Up));
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value);
}
@ -126,11 +126,11 @@ namespace osu.Game.Tests.Visual.Gameplay
{
AddStep("Show overlay", () => failOverlay.Show());
AddStep("Down arrow", () => press(Key.Down));
AddStep("Down arrow", () => InputManager.Key(Key.Down));
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value);
AddStep("Down arrow", () => press(Key.Down));
AddStep("Down arrow", () => InputManager.Key(Key.Down));
AddAssert("Last button selected", () => failOverlay.Buttons.Last().Selected.Value);
AddStep("Down arrow", () => press(Key.Down));
AddStep("Down arrow", () => InputManager.Key(Key.Down));
AddAssert("First button selected", () => failOverlay.Buttons.First().Selected.Value);
}
@ -177,7 +177,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
showOverlay();
AddStep("Down arrow", () => press(Key.Down));
AddStep("Down arrow", () => InputManager.Key(Key.Down));
AddStep("Hover second button", () => InputManager.MoveMouseTo(getButton(1)));
AddAssert("First button not selected", () => !getButton(0).Selected.Value);
AddAssert("Second button selected", () => getButton(1).Selected.Value);
@ -195,7 +195,7 @@ namespace osu.Game.Tests.Visual.Gameplay
});
AddStep("Hover second button", () => InputManager.MoveMouseTo(getButton(1)));
AddStep("Up arrow", () => press(Key.Up));
AddStep("Up arrow", () => InputManager.Key(Key.Up));
AddAssert("Second button not selected", () => !getButton(1).Selected.Value);
AddAssert("First button selected", () => getButton(0).Selected.Value);
}
@ -210,7 +210,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("Hover second button", () => InputManager.MoveMouseTo(getButton(1)));
AddStep("Unhover second button", () => InputManager.MoveMouseTo(Vector2.Zero));
AddStep("Down arrow", () => press(Key.Down));
AddStep("Down arrow", () => InputManager.Key(Key.Down));
AddAssert("First button selected", () => getButton(0).Selected.Value); // Initial state condition
}
@ -246,8 +246,8 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("Select second button", () =>
{
press(Key.Down);
press(Key.Down);
InputManager.Key(Key.Down);
InputManager.Key(Key.Down);
});
bool triggered = false;
@ -256,7 +256,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
lastAction = pauseOverlay.OnRetry;
pauseOverlay.OnRetry = () => triggered = true;
press(Key.Enter);
InputManager.Key(Key.Enter);
});
AddAssert("Action was triggered", () =>
@ -290,12 +290,6 @@ namespace osu.Game.Tests.Visual.Gameplay
private DialogButton getButton(int index) => pauseOverlay.Buttons.Skip(index).First();
private void press(Key key)
{
InputManager.PressKey(key);
InputManager.ReleaseKey(key);
}
private void press(GlobalAction action)
{
globalActionContainer.TriggerPressed(action);

View File

@ -32,11 +32,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestDefaultsWhenNotDatabased()
{
AddStep("fire key", () =>
{
InputManager.PressKey(Key.A);
InputManager.ReleaseKey(Key.A);
});
AddStep("fire key", () => InputManager.Key(Key.A));
AddAssert("received key", () => receiver.ReceivedAction);
}

View File

@ -40,11 +40,7 @@ namespace osu.Game.Tests.Visual.Gameplay
void addPressKeyStep()
{
AddStep($"Press {testKey} key", () =>
{
InputManager.PressKey(testKey);
InputManager.ReleaseKey(testKey);
});
AddStep($"Press {testKey} key", () => InputManager.Key(testKey));
}
addPressKeyStep();

View File

@ -59,11 +59,7 @@ namespace osu.Game.Tests.Visual.Gameplay
confirmClockRunning(false);
confirmPauseOverlayShown(false);
AddStep("click to resume", () =>
{
InputManager.PressButton(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
});
AddStep("click to resume", () => InputManager.Click(MouseButton.Left));
confirmClockRunning(true);
}

View File

@ -158,8 +158,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("much move with press", () => moveFunction = Scheduler.AddDelayed(() =>
{
InputManager.MoveMouseTo(InputManager.CurrentState.Mouse.Position + new Vector2(-1, 0));
InputManager.PressButton(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
InputManager.Click(MouseButton.Left);
}, 10, true));
AddWaitStep("move", 10);
AddStep("stop move", () => moveFunction.Cancel());

View File

@ -65,10 +65,8 @@ namespace osu.Game.Tests.Visual.Menus
AddStep($"switch to ruleset {i} via shortcut", () =>
{
InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(numberKey);
InputManager.Key(numberKey);
InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(numberKey);
});
AddUntilStep("ruleset switched", () => rulesetSelector.Current.Value.Equals(expected));

View File

@ -71,11 +71,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
private void press(Key down)
{
AddStep($"press {down}", () =>
{
InputManager.PressKey(down);
InputManager.ReleaseKey(down);
});
AddStep($"press {down}", () => InputManager.Key(down));
}
[Test]

View File

@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.Navigation
if (withUserPause)
AddStep("pause", () => Game.Dependencies.Get<MusicController>().Stop(true));
AddStep("press enter", () => pressAndRelease(Key.Enter));
AddStep("press enter", () => InputManager.Key(Key.Enter));
AddUntilStep("wait for player", () => (player = Game.ScreenStack.CurrentScreen as Player) != null);
AddUntilStep("wait for fail", () => player.HasFailed);
@ -122,11 +122,11 @@ namespace osu.Game.Tests.Visual.Navigation
public void TestOpenOptionsAndExitWithEscape()
{
AddUntilStep("Wait for options to load", () => Game.Settings.IsLoaded);
AddStep("Enter menu", () => pressAndRelease(Key.Enter));
AddStep("Enter menu", () => InputManager.Key(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);
AddStep("Hide options overlay using escape", () => pressAndRelease(Key.Escape));
AddStep("Hide options overlay using escape", () => InputManager.Key(Key.Escape));
AddAssert("Options overlay was closed", () => Game.Settings.State.Value == Visibility.Hidden);
}
@ -158,10 +158,8 @@ namespace osu.Game.Tests.Visual.Navigation
AddStep("Change ruleset to osu!taiko", () =>
{
InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(Key.Number2);
InputManager.Key(Key.Number2);
InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(Key.Number2);
});
AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType<ToolbarRulesetSelector>().Single().Current.Value.ID == 1);
@ -181,10 +179,8 @@ namespace osu.Game.Tests.Visual.Navigation
AddStep("Change ruleset to osu!taiko", () =>
{
InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(Key.Number2);
InputManager.Key(Key.Number2);
InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(Key.Number2);
});
AddAssert("Ruleset changed to osu!taiko", () => Game.Toolbar.ChildrenOfType<ToolbarRulesetSelector>().Single().Current.Value.ID == 1);
@ -193,7 +189,7 @@ namespace osu.Game.Tests.Visual.Navigation
}
private void pushEscape() =>
AddStep("Press escape", () => pressAndRelease(Key.Escape));
AddStep("Press escape", () => InputManager.Key(Key.Escape));
private void exitViaEscapeAndConfirm()
{
@ -208,12 +204,6 @@ namespace osu.Game.Tests.Visual.Navigation
ConfirmAtMainMenu();
}
private void pressAndRelease(Key key)
{
InputManager.PressKey(key);
InputManager.ReleaseKey(key);
}
private class TestSongSelect : PlaySongSelect
{
public ModSelectOverlay ModSelectOverlay => ModSelect;

View File

@ -103,11 +103,7 @@ namespace osu.Game.Tests.Visual.Online
public void TestChannelShortcutKeys()
{
AddStep("Join channels", () => channels.ForEach(channel => channelManager.JoinChannel(channel)));
AddStep("Close channel selector", () =>
{
InputManager.PressKey(Key.Escape);
InputManager.ReleaseKey(Key.Escape);
});
AddStep("Close channel selector", () => InputManager.Key(Key.Escape));
AddUntilStep("Wait for close", () => chatOverlay.SelectionOverlayState == Visibility.Hidden);
for (int zeroBasedIndex = 0; zeroBasedIndex < 10; ++zeroBasedIndex)
@ -216,9 +212,8 @@ namespace osu.Game.Tests.Visual.Online
{
var channelKey = Key.Number0 + number;
InputManager.PressKey(Key.AltLeft);
InputManager.PressKey(channelKey);
InputManager.Key(channelKey);
InputManager.ReleaseKey(Key.AltLeft);
InputManager.ReleaseKey(channelKey);
}
private void clickDrawable(Drawable d)

View File

@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual.Online
[Test]
public void TestGenericActivity()
{
AddStep("Set activity", () => API.Activity.Value = new UserActivity.InLobby());
AddStep("Set activity", () => API.Activity.Value = new UserActivity.InLobby(null));
AddStep("Run command", () => Add(new NowPlayingCommand()));
@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.Online
[TestCase(false)]
public void TestLinkPresence(bool hasOnlineId)
{
AddStep("Set activity", () => API.Activity.Value = new UserActivity.InLobby());
AddStep("Set activity", () => API.Activity.Value = new UserActivity.InLobby(null));
AddStep("Set beatmap", () => Beatmap.Value = new DummyWorkingBeatmap(Audio, null)
{

View File

@ -51,8 +51,7 @@ namespace osu.Game.Tests.Visual.Settings
clickDelegate = Scheduler.AddDelayed(() =>
{
InputManager.PressButton(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
InputManager.Click(MouseButton.Left);
if (++buttonClicks == 2)
{

View File

@ -98,10 +98,8 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("select next and enter", () =>
{
InputManager.PressKey(Key.Down);
InputManager.ReleaseKey(Key.Down);
InputManager.PressKey(Key.Enter);
InputManager.ReleaseKey(Key.Enter);
InputManager.Key(Key.Down);
InputManager.Key(Key.Enter);
});
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
@ -123,10 +121,8 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("select next and enter", () =>
{
InputManager.PressKey(Key.Enter);
InputManager.ReleaseKey(Key.Enter);
InputManager.PressKey(Key.Down);
InputManager.ReleaseKey(Key.Down);
InputManager.Key(Key.Enter);
InputManager.Key(Key.Down);
});
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
@ -151,11 +147,9 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
.First(b => ((CarouselBeatmap)b.Item).Beatmap != songSelect.Carousel.SelectedBeatmap));
InputManager.PressButton(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
InputManager.Click(MouseButton.Left);
InputManager.PressKey(Key.Enter);
InputManager.ReleaseKey(Key.Enter);
InputManager.Key(Key.Enter);
});
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
@ -182,8 +176,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.PressButton(MouseButton.Left);
InputManager.PressKey(Key.Enter);
InputManager.ReleaseKey(Key.Enter);
InputManager.Key(Key.Enter);
InputManager.ReleaseButton(MouseButton.Left);
});
@ -567,10 +560,8 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("press ctrl+enter", () =>
{
InputManager.PressKey(Key.ControlLeft);
InputManager.PressKey(Key.Enter);
InputManager.Key(Key.Enter);
InputManager.ReleaseKey(Key.ControlLeft);
InputManager.ReleaseKey(Key.Enter);
});
AddUntilStep("wait for player", () => Stack.CurrentScreen is PlayerLoader);
@ -617,8 +608,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
InputManager.MoveMouseTo(difficultyIcon);
InputManager.PressButton(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
InputManager.Click(MouseButton.Left);
});
AddAssert("Selected beatmap correct", () => getCurrentBeatmapIndex() == getDifficultyIconIndex(set, difficultyIcon));
@ -647,8 +637,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
InputManager.MoveMouseTo(filteredIcon);
InputManager.PressButton(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
InputManager.Click(MouseButton.Left);
});
AddAssert("Selected beatmap correct", () => songSelect.Carousel.SelectedBeatmap == filteredBeatmap);
@ -691,8 +680,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
InputManager.MoveMouseTo(difficultyIcon);
InputManager.PressButton(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
InputManager.Click(MouseButton.Left);
});
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3);
@ -738,8 +726,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
InputManager.MoveMouseTo(groupIcon);
InputManager.PressButton(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
InputManager.Click(MouseButton.Left);
});
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3);

View File

@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual.UserInterface
});
AddStep("enter text", () => commentEditor.Current.Value = "text");
AddStep("press Enter", () => press(Key.Enter));
AddStep("press Enter", () => InputManager.Key(Key.Enter));
AddAssert("text committed", () => commentEditor.CommittedText == "text");
AddAssert("button is loading", () => commentEditor.IsLoading);
@ -63,7 +63,7 @@ namespace osu.Game.Tests.Visual.UserInterface
InputManager.Click(MouseButton.Left);
});
AddStep("press Enter", () => press(Key.Enter));
AddStep("press Enter", () => InputManager.Key(Key.Enter));
AddAssert("no text committed", () => commentEditor.CommittedText == null);
AddAssert("button is not loading", () => !commentEditor.IsLoading);
@ -101,12 +101,6 @@ namespace osu.Game.Tests.Visual.UserInterface
AddAssert("cancel action fired", () => cancellableCommentEditor.Cancelled);
}
private void press(Key key)
{
InputManager.PressKey(key);
InputManager.ReleaseKey(key);
}
private class TestCommentEditor : CommentEditor
{
public new Bindable<string> Current => base.Current;

View File

@ -11,9 +11,9 @@
"build",
"--no-restore",
"osu.Game.Tournament.Tests.csproj",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"
@ -26,10 +26,10 @@
"build",
"--no-restore",
"osu.Game.Tournament.Tests.csproj",
"/p:Configuration=Release",
"/p:GenerateFullPaths=true",
"/m",
"/verbosity:m"
"-p:Configuration=Release",
"-p:GenerateFullPaths=true",
"-m",
"-verbosity:m"
],
"group": "build",
"problemMatcher": "$msCompile"

View File

@ -30,8 +30,22 @@ namespace osu.Game.Beatmaps
// Too many simultaneous updates can lead to stutters. One thread seems to work fine for song select display purposes.
private readonly ThreadedTaskScheduler updateScheduler = new ThreadedTaskScheduler(1, nameof(BeatmapDifficultyCache));
// All bindables that should be updated along with the current ruleset + mods.
private readonly LockedWeakList<BindableStarDifficulty> trackedBindables = new LockedWeakList<BindableStarDifficulty>();
/// <summary>
/// All bindables that should be updated along with the current ruleset + mods.
/// </summary>
private readonly WeakList<BindableStarDifficulty> trackedBindables = new WeakList<BindableStarDifficulty>();
/// <summary>
/// Cancellation sources used by tracked bindables.
/// </summary>
private readonly List<CancellationTokenSource> linkedCancellationSources = new List<CancellationTokenSource>();
/// <summary>
/// Lock to be held when operating on <see cref="trackedBindables"/> or <see cref="linkedCancellationSources"/>.
/// </summary>
private readonly object bindableUpdateLock = new object();
private CancellationTokenSource trackedUpdateCancellationSource;
[Resolved]
private BeatmapManager beatmapManager { get; set; }
@ -59,7 +73,10 @@ namespace osu.Game.Beatmaps
public IBindable<StarDifficulty> GetBindableDifficulty([NotNull] BeatmapInfo beatmapInfo, CancellationToken cancellationToken = default)
{
var bindable = createBindable(beatmapInfo, currentRuleset.Value, currentMods.Value, cancellationToken);
trackedBindables.Add(bindable);
lock (bindableUpdateLock)
trackedBindables.Add(bindable);
return bindable;
}
@ -86,7 +103,8 @@ namespace osu.Game.Beatmaps
/// <param name="mods">The <see cref="Mod"/>s to get the difficulty with.</param>
/// <param name="cancellationToken">An optional <see cref="CancellationToken"/> which stops computing the star difficulty.</param>
/// <returns>The <see cref="StarDifficulty"/>.</returns>
public Task<StarDifficulty> GetDifficultyAsync([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo rulesetInfo = null, [CanBeNull] IEnumerable<Mod> mods = null, CancellationToken cancellationToken = default)
public Task<StarDifficulty> GetDifficultyAsync([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo rulesetInfo = null, [CanBeNull] IEnumerable<Mod> mods = null,
CancellationToken cancellationToken = default)
{
// In the case that the user hasn't given us a ruleset, use the beatmap's default ruleset.
rulesetInfo ??= beatmapInfo.Ruleset;
@ -140,23 +158,23 @@ namespace osu.Game.Beatmaps
return DifficultyRating.Easy;
}
private CancellationTokenSource trackedUpdateCancellationSource;
private readonly List<CancellationTokenSource> linkedCancellationSources = new List<CancellationTokenSource>();
/// <summary>
/// Updates all tracked <see cref="BindableStarDifficulty"/> using the current ruleset and mods.
/// </summary>
private void updateTrackedBindables()
{
cancelTrackedBindableUpdate();
trackedUpdateCancellationSource = new CancellationTokenSource();
foreach (var b in trackedBindables)
lock (bindableUpdateLock)
{
var linkedSource = CancellationTokenSource.CreateLinkedTokenSource(trackedUpdateCancellationSource.Token, b.CancellationToken);
linkedCancellationSources.Add(linkedSource);
cancelTrackedBindableUpdate();
trackedUpdateCancellationSource = new CancellationTokenSource();
updateBindable(b, currentRuleset.Value, currentMods.Value, linkedSource.Token);
foreach (var b in trackedBindables)
{
var linkedSource = CancellationTokenSource.CreateLinkedTokenSource(trackedUpdateCancellationSource.Token, b.CancellationToken);
linkedCancellationSources.Add(linkedSource);
updateBindable(b, currentRuleset.Value, currentMods.Value, linkedSource.Token);
}
}
}
@ -165,15 +183,18 @@ namespace osu.Game.Beatmaps
/// </summary>
private void cancelTrackedBindableUpdate()
{
trackedUpdateCancellationSource?.Cancel();
trackedUpdateCancellationSource = null;
if (linkedCancellationSources != null)
lock (bindableUpdateLock)
{
foreach (var c in linkedCancellationSources)
c.Dispose();
trackedUpdateCancellationSource?.Cancel();
trackedUpdateCancellationSource = null;
linkedCancellationSources.Clear();
if (linkedCancellationSources != null)
{
foreach (var c in linkedCancellationSources)
c.Dispose();
linkedCancellationSources.Clear();
}
}
}

View File

@ -51,6 +51,7 @@ using osu.Game.Screens.Select;
using osu.Game.Updater;
using osu.Game.Utils;
using LogLevel = osu.Framework.Logging.LogLevel;
using osu.Game.Users;
namespace osu.Game
{
@ -961,11 +962,15 @@ namespace osu.Game
LocalUserPlaying.Value = false;
if (current is IOsuScreen currentOsuScreen)
{
OverlayActivationMode.UnbindFrom(currentOsuScreen.OverlayActivationMode);
API.Activity.UnbindFrom(currentOsuScreen.Activity);
}
if (newScreen is IOsuScreen newOsuScreen)
{
OverlayActivationMode.BindTo(newOsuScreen.OverlayActivationMode);
((IBindable<UserActivity>)API.Activity).BindTo(newOsuScreen.Activity);
MusicController.AllowRateAdjustments = newOsuScreen.AllowRateAdjustments;

View File

@ -32,6 +32,11 @@ namespace osu.Game.Overlays.BeatmapListing
/// </summary>
public Action SearchStarted;
/// <summary>
/// Any time the search text box receives key events (even while masked).
/// </summary>
public Action TypingStarted;
/// <summary>
/// True when pagination has reached the end of available results.
/// </summary>
@ -82,7 +87,10 @@ namespace osu.Game.Overlays.BeatmapListing
Radius = 3,
Offset = new Vector2(0f, 1f),
},
Child = searchControl = new BeatmapListingSearchControl(),
Child = searchControl = new BeatmapListingSearchControl
{
TypingStarted = () => TypingStarted?.Invoke()
}
},
new Container
{

View File

@ -1,12 +1,14 @@
// 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osuTK;
using osu.Framework.Bindables;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
@ -19,6 +21,11 @@ namespace osu.Game.Overlays.BeatmapListing
{
public class BeatmapListingSearchControl : CompositeDrawable
{
/// <summary>
/// Any time the text box receives key events (even while masked).
/// </summary>
public Action TypingStarted;
public Bindable<string> Query => textBox.Current;
public Bindable<RulesetInfo> Ruleset => modeFilter.Current;
@ -102,6 +109,7 @@ namespace osu.Game.Overlays.BeatmapListing
textBox = new BeatmapSearchTextBox
{
RelativeSizeAxes = Axes.X,
TypingStarted = () => TypingStarted?.Invoke(),
},
new ReverseChildIDFillFlowContainer<Drawable>
{
@ -138,12 +146,26 @@ namespace osu.Game.Overlays.BeatmapListing
private class BeatmapSearchTextBox : SearchTextBox
{
/// <summary>
/// Any time the text box receives key events (even while masked).
/// </summary>
public Action TypingStarted;
protected override Color4 SelectionColour => Color4.Gray;
public BeatmapSearchTextBox()
{
PlaceholderText = @"type in keywords...";
}
protected override bool OnKeyDown(KeyDownEvent e)
{
if (!base.OnKeyDown(e))
return false;
TypingStarted?.Invoke();
return true;
}
}
}
}

View File

@ -68,6 +68,7 @@ namespace osu.Game.Overlays
Header,
filterControl = new BeatmapListingFilterControl
{
TypingStarted = onTypingStarted,
SearchStarted = onSearchStarted,
SearchFinished = onSearchFinished,
},
@ -102,6 +103,12 @@ namespace osu.Game.Overlays
};
}
private void onTypingStarted()
{
// temporary until the textbox/header is updated to always stay on screen.
resultScrollContainer.ScrollToStart();
}
protected override void OnFocus(FocusEvent e)
{
base.OnFocus(e);

View File

@ -110,7 +110,11 @@ namespace osu.Game.Overlays.Dashboard
User = user;
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(IAPIProvider api)
{
InternalChildren = new Drawable[]
{
new FillFlowContainer
@ -121,7 +125,7 @@ namespace osu.Game.Overlays.Dashboard
Width = 290,
Children = new Drawable[]
{
new UserGridPanel(user)
new UserGridPanel(User)
{
RelativeSizeAxes = Axes.X,
Anchor = Anchor.TopCentre,
@ -133,7 +137,8 @@ namespace osu.Game.Overlays.Dashboard
Text = "Watch",
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Action = () => game?.PerformFromScreen(s => s.Push(new Spectator(user)))
Action = () => game?.PerformFromScreen(s => s.Push(new Spectator(User))),
Enabled = { Value = User.Id != api.LocalUser.Value.Id }
}
}
},

View File

@ -303,7 +303,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
if (blueprint.IsHovered)
{
selectedPerformed &= SelectionHandler.HandleSelectionRequested(blueprint, e.CurrentState);
selectedPerformed &= SelectionHandler.HandleSelectionRequested(blueprint, e);
clickSelectionBegan = true;
break;
}

View File

@ -14,7 +14,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.States;
using osu.Framework.Input.Events;
using osu.Game.Audio;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
@ -218,17 +218,17 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// Handle a blueprint requesting selection.
/// </summary>
/// <param name="blueprint">The blueprint.</param>
/// <param name="state">The input state at the point of selection.</param>
/// <param name="e">The mouse event responsible for selection.</param>
/// <returns>Whether a selection was performed.</returns>
internal bool HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
internal bool HandleSelectionRequested(SelectionBlueprint blueprint, MouseButtonEvent e)
{
if (state.Keyboard.ShiftPressed && state.Mouse.IsPressed(MouseButton.Right))
if (e.ShiftPressed && e.Button == MouseButton.Right)
{
handleQuickDeletion(blueprint);
return false;
}
if (state.Keyboard.ControlPressed && state.Mouse.IsPressed(MouseButton.Left))
if (e.ControlPressed && e.Button == MouseButton.Left)
blueprint.ToggleSelection();
else
ensureSelected(blueprint);

View File

@ -6,6 +6,7 @@ using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Users;
namespace osu.Game.Screens
{
@ -43,6 +44,11 @@ namespace osu.Game.Screens
/// </summary>
IBindable<OverlayActivation> OverlayActivationMode { get; }
/// <summary>
/// The current <see cref="UserActivity"/> for this screen.
/// </summary>
IBindable<UserActivity> Activity { get; }
/// <summary>
/// The amount of parallax to be applied while this screen is displayed.
/// </summary>

View File

@ -14,6 +14,7 @@ using osu.Game.Online.Multiplayer;
using osu.Game.Overlays;
using osu.Game.Screens.Multi.Lounge.Components;
using osu.Game.Screens.Multi.Match;
using osu.Game.Users;
namespace osu.Game.Screens.Multi.Lounge
{
@ -24,6 +25,8 @@ namespace osu.Game.Screens.Multi.Lounge
protected FilterControl Filter;
protected override UserActivity InitialActivity => new UserActivity.SearchingForLobby();
private readonly Bindable<bool> initialRoomsReceived = new Bindable<bool>();
private Container content;

View File

@ -21,6 +21,7 @@ using osu.Game.Screens.Multi.Play;
using osu.Game.Screens.Multi.Ranking;
using osu.Game.Screens.Play;
using osu.Game.Screens.Select;
using osu.Game.Users;
using Footer = osu.Game.Screens.Multi.Match.Components.Footer;
namespace osu.Game.Screens.Multi.Match
@ -60,6 +61,7 @@ namespace osu.Game.Screens.Multi.Match
public MatchSubScreen(Room room)
{
Title = room.RoomID.Value == null ? "New room" : room.Name.Value;
Activity.Value = new UserActivity.InLobby(room);
}
[BackgroundDependencyLoader]

View File

@ -24,6 +24,7 @@ using osu.Game.Screens.Multi.Lounge;
using osu.Game.Screens.Multi.Lounge.Components;
using osu.Game.Screens.Multi.Match;
using osu.Game.Screens.Multi.Match.Components;
using osu.Game.Users;
using osuTK;
namespace osu.Game.Screens.Multi
@ -140,10 +141,10 @@ namespace osu.Game.Screens.Multi
}
};
screenStack.Push(loungeSubScreen = new LoungeSubScreen());
screenStack.ScreenPushed += screenPushed;
screenStack.ScreenExited += screenExited;
screenStack.Push(loungeSubScreen = new LoungeSubScreen());
}
private readonly IBindable<APIState> apiState = new Bindable<APIState>();
@ -311,18 +312,18 @@ namespace osu.Game.Screens.Multi
private void screenPushed(IScreen lastScreen, IScreen newScreen)
{
subScreenChanged(newScreen);
subScreenChanged(lastScreen, newScreen);
}
private void screenExited(IScreen lastScreen, IScreen newScreen)
{
subScreenChanged(newScreen);
subScreenChanged(lastScreen, newScreen);
if (screenStack.CurrentScreen == null && this.IsCurrentScreen())
this.Exit();
}
private void subScreenChanged(IScreen newScreen)
private void subScreenChanged(IScreen lastScreen, IScreen newScreen)
{
switch (newScreen)
{
@ -337,6 +338,12 @@ namespace osu.Game.Screens.Multi
break;
}
if (lastScreen is IOsuScreen lastOsuScreen)
Activity.UnbindFrom(lastOsuScreen.Activity);
if (newScreen is IOsuScreen newOsuScreen)
((IBindable<UserActivity>)Activity).BindTo(newOsuScreen.Activity);
updatePollingRate(isIdle.Value);
createButton.FadeTo(newScreen is LoungeSubScreen ? 1 : 0, 200);

View File

@ -14,7 +14,6 @@ using osu.Game.Rulesets;
using osu.Game.Screens.Menu;
using osu.Game.Overlays;
using osu.Game.Users;
using osu.Game.Online.API;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Screens
@ -57,28 +56,18 @@ namespace osu.Game.Screens
protected new OsuGameBase Game => base.Game as OsuGameBase;
/// <summary>
/// The <see cref="UserActivity"/> to set the user's activity automatically to when this screen is entered
/// <para>This <see cref="Activity"/> will be automatically set to <see cref="InitialActivity"/> for this screen on entering unless
/// <see cref="Activity"/> is manually set before.</para>
/// The <see cref="UserActivity"/> to set the user's activity automatically to when this screen is entered.
/// <para>This <see cref="Activity"/> will be automatically set to <see cref="InitialActivity"/> for this screen on entering for the first time
/// unless <see cref="Activity"/> is manually set before.</para>
/// </summary>
protected virtual UserActivity InitialActivity => null;
private UserActivity activity;
/// <summary>
/// The current <see cref="UserActivity"/> for this screen.
/// </summary>
protected UserActivity Activity
{
get => activity;
set
{
if (value == activity) return;
protected readonly Bindable<UserActivity> Activity = new Bindable<UserActivity>();
activity = value;
updateActivity();
}
}
IBindable<UserActivity> IOsuScreen.Activity => Activity;
/// <summary>
/// Whether to disallow changes to game-wise Beatmap/Ruleset bindables for this screen (and all children).
@ -135,9 +124,6 @@ namespace osu.Game.Screens
[Resolved(canBeNull: true)]
private OsuLogo logo { get; set; }
[Resolved(canBeNull: true)]
private IAPIProvider api { get; set; }
protected OsuScreen()
{
Anchor = Anchor.Centre;
@ -150,6 +136,8 @@ namespace osu.Game.Screens
private void load(OsuGame osu, AudioManager audio)
{
sampleExit = audio.Samples.Get(@"UI/screen-back");
Activity.Value ??= InitialActivity;
}
public override void OnResuming(IScreen last)
@ -158,8 +146,6 @@ namespace osu.Game.Screens
sampleExit?.Play();
applyArrivingDefaults(true);
updateActivity();
base.OnResuming(last);
}
@ -176,9 +162,6 @@ namespace osu.Game.Screens
backgroundStack?.Push(localBackground = CreateBackground());
if (activity == null)
Activity = InitialActivity;
base.OnEntering(last);
}
@ -196,12 +179,6 @@ namespace osu.Game.Screens
return false;
}
private void updateActivity()
{
if (api != null)
api.Activity.Value = activity;
}
/// <summary>
/// Fired when this screen was entered or resumed and the logo state is required to be adjusted.
/// </summary>

View File

@ -80,7 +80,7 @@ namespace osu.Game.Skinning
Math.Clamp(Clock.ElapsedFrameTime, 0, 200),
fill.Width, (float)Current.Value * maxFillWidth, 0, 200, Easing.OutQuint);
marker.Position = fill.Position + new Vector2(fill.DrawWidth, fill.DrawHeight / 2);
marker.Position = fill.Position + new Vector2(fill.DrawWidth, isNewStyle ? fill.DrawHeight / 2 : 0);
}
public void Flash(JudgementResult result) => marker.Flash(result);

View File

@ -186,7 +186,7 @@ namespace osu.Game.Users
}
}
[JsonProperty(@"rankHistory")]
[JsonProperty(@"rank_history")]
private RankHistoryData rankHistory
{
set => statistics.RankHistory = value;

View File

@ -3,6 +3,7 @@
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets;
using osuTK.Graphics;
@ -61,9 +62,21 @@ namespace osu.Game.Users
public override string Status => @"Spectating a game";
}
public class SearchingForLobby : UserActivity
{
public override string Status => @"Looking for a lobby";
}
public class InLobby : UserActivity
{
public override string Status => @"In a multiplayer lobby";
public readonly Room Room;
public InLobby(Room room)
{
Room = room;
}
}
}
}