1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 17:27:39 +08:00

Merge branch 'master' into hard-rock-pattern

This commit is contained in:
Dan Balasescu 2021-06-23 17:08:59 +09:00 committed by GitHub
commit 29d45a387b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 94 additions and 24 deletions

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="osu-client-sqlite" uuid="1aa4b9be-cd8d-47ae-8186-30a13cd724a5">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:$USER_HOME$/.local/share/osu/client.db</jdbc-url>
<driver-properties>
<property name="enable_load_extension" value="true" />
</driver-properties>
</data-source>
</component>
</project>

View File

@ -55,7 +55,12 @@ namespace osu.Game.Tests.Visual.Editing
[Test]
public void TestExitWithoutSave()
{
AddStep("exit without save", () => Editor.Exit());
AddStep("exit without save", () =>
{
Editor.Exit();
DialogOverlay.CurrentDialog.PerformOkAction();
});
AddUntilStep("wait for exit", () => !Editor.IsCurrentScreen());
AddAssert("new beatmap not persisted", () => beatmapManager.QueryBeatmapSet(s => s.ID == EditorBeatmap.BeatmapInfo.BeatmapSet.ID)?.DeletePending == true);
}

View File

@ -6,15 +6,20 @@ using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Graphics.Containers;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Screens.OnlinePlay.Components;
using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.OnlinePlay.Multiplayer;
using osu.Game.Screens.OnlinePlay.Multiplayer.Match;
using osu.Game.Tests.Resources;
@ -159,6 +164,50 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("play started", () => !multiplayerScreen.IsCurrentScreen());
}
[Test]
public void TestLeaveNavigation()
{
loadMultiplayer();
createRoom(() => new Room
{
Name = { Value = "Test Room" },
Playlist =
{
new PlaylistItem
{
Beatmap = { Value = beatmaps.GetWorkingBeatmap(importedSet.Beatmaps.First(b => b.RulesetID == 0)).BeatmapInfo },
Ruleset = { Value = new OsuRuleset().RulesetInfo },
AllowedMods = { new OsuModHidden() }
}
}
});
AddStep("open mod overlay", () => this.ChildrenOfType<PurpleTriangleButton>().ElementAt(2).Click());
AddStep("invoke on back button", () => multiplayerScreen.OnBackButton());
AddAssert("mod overlay is hidden", () => this.ChildrenOfType<LocalPlayerModSelectOverlay>().Single().State.Value == Visibility.Hidden);
AddAssert("dialog overlay is hidden", () => DialogOverlay.State.Value == Visibility.Hidden);
testLeave("lounge tab item", () => this.ChildrenOfType<BreadcrumbControl<IScreen>.BreadcrumbTabItem>().First().Click());
testLeave("back button", () => multiplayerScreen.OnBackButton());
// mimics home button and OS window close
testLeave("forced exit", () => multiplayerScreen.Exit());
void testLeave(string actionName, Action action)
{
AddStep($"leave via {actionName}", action);
AddAssert("dialog overlay is visible", () => DialogOverlay.State.Value == Visibility.Visible);
AddStep("close dialog overlay", () => InputManager.Key(Key.Escape));
}
}
private void createRoom(Func<Room> room)
{
AddStep("open room", () =>

View File

@ -3,6 +3,7 @@
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Screens;
namespace osu.Game.Graphics.UserInterface
@ -19,8 +20,13 @@ namespace osu.Game.Graphics.UserInterface
if (stack.CurrentScreen != null)
onPushed(null, stack.CurrentScreen);
}
Current.ValueChanged += current => current.NewValue.MakeCurrent();
protected override void SelectTab(TabItem<IScreen> tab)
{
// override base method to prevent current item from being changed on click.
// depend on screen push/exit to change current item instead.
tab.Value.MakeCurrent();
}
private void onPushed(IScreen lastScreen, IScreen newScreen)

View File

@ -258,7 +258,7 @@ namespace osu.Game
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, API, contextFactory, Host, () => difficultyCache, LocalConfig));
dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, contextFactory, RulesetStore, API, Audio, Resources, Host, defaultBeatmap, true));
// this should likely be moved to ArchiveModelManager when another case appers where it is necessary
// this should likely be moved to ArchiveModelManager when another case appears where it is necessary
// to have inter-dependent model managers. this could be obtained with an IHasForeign<T> interface to
// allow lookups to be done on the child (ScoreManager in this case) to perform the cascading delete.
List<ScoreInfo> getBeatmapScores(BeatmapSetInfo set)

View File

@ -305,18 +305,34 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
return true;
}
return base.OnBackButton();
}
public override bool OnExiting(IScreen next)
{
if (client.Room == null)
{
// room has not been created yet; exit immediately.
return base.OnExiting(next);
}
if (!exitConfirmed && dialogOverlay != null)
{
if (dialogOverlay.CurrentDialog is ConfirmDialog confirmDialog)
confirmDialog.PerformOkAction();
else
{
dialogOverlay.Push(new ConfirmDialog("Are you sure you want to leave this multiplayer match?", () =>
{
exitConfirmed = true;
this.Exit();
}));
}
return true;
}
return base.OnBackButton();
return base.OnExiting(next);
}
private ModSettingChangeTracker modSettingChangeTracker;

View File

@ -240,13 +240,15 @@ namespace osu.Game.Screens.OnlinePlay
public override bool OnExiting(IScreen next)
{
if (screenStack.CurrentScreen?.OnExiting(next) == true)
return true;
RoomManager.PartRoom();
waves.Hide();
this.Delay(WaveContainer.DISAPPEAR_DURATION).FadeOut();
screenStack.CurrentScreen?.OnExiting(next);
base.OnExiting(next);
return false;
}

View File

@ -1,9 +1,11 @@
// 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Overlays;
using osu.Game.Screens;
namespace osu.Game.Tests.Visual
@ -19,12 +21,16 @@ namespace osu.Game.Tests.Visual
protected override Container<Drawable> Content => content;
[Cached]
protected DialogOverlay DialogOverlay { get; private set; }
protected ScreenTestScene()
{
base.Content.AddRange(new Drawable[]
{
Stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both },
content = new Container { RelativeSizeAxes = Axes.Both }
content = new Container { RelativeSizeAxes = Axes.Both },
DialogOverlay = new DialogOverlay()
});
}