mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 09:42:54 +08:00
Compare commits
9 Commits
1b9e437d6b
...
5c8f0b4d74
Author | SHA1 | Date | |
---|---|---|---|
|
5c8f0b4d74 | ||
|
be05f2a1c2 | ||
|
6ff1dec7b2 | ||
|
ce4aac4184 | ||
|
e920cfa187 | ||
|
164b809c89 | ||
|
f4e155bfa6 | ||
|
3cfa455369 | ||
|
58cf1c11e4 |
@ -144,6 +144,13 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
|
||||
foreach (var nested in hitObject.NestedHitObjects)
|
||||
simulateHit(nested, ref attributes);
|
||||
return;
|
||||
|
||||
case StrongNestedHitObject:
|
||||
// we never need to deal with these directly.
|
||||
// the only thing strong hits do in terms of scoring is double their object's score increase,
|
||||
// which is already handled at the parent object level via the `strongable.IsStrong` check lower down in this method.
|
||||
// not handling these here can lead to them falsely being counted as combo-increasing when handling strong drum rolls!
|
||||
return;
|
||||
}
|
||||
|
||||
if (hitObject is DrumRollTick tick)
|
||||
|
@ -5,25 +5,64 @@ using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Extensions;
|
||||
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.API;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Online.Rooms.RoomStatuses;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.OnlinePlay.Playlists;
|
||||
using osu.Game.Tests.Resources;
|
||||
using osu.Game.Tests.Visual.OnlinePlay;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Playlists
|
||||
{
|
||||
public partial class TestScenePlaylistsRoomSubScreen : OnlinePlayTestScene
|
||||
{
|
||||
private const double track_length = 10000;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
protected new TestRoomManager RoomManager => (TestRoomManager)base.RoomManager;
|
||||
|
||||
private BeatmapManager beatmaps = null!;
|
||||
private RulesetStore rulesets = null!;
|
||||
private BeatmapSetInfo? importedSet;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, AudioManager audio)
|
||||
{
|
||||
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
||||
Dependencies.Cache(beatmaps = new BeatmapManager(LocalStorage, Realm, null, audio, Resources, host, Beatmap.Default));
|
||||
Dependencies.Cache(new ScoreManager(rulesets, () => beatmaps, LocalStorage, Realm, API));
|
||||
Dependencies.Cache(Realm);
|
||||
|
||||
beatmaps.Import(TestResources.GetQuickTestBeatmapForImport()).WaitSafely();
|
||||
|
||||
Realm.Write(r =>
|
||||
{
|
||||
foreach (var set in r.All<BeatmapSetInfo>())
|
||||
{
|
||||
foreach (var b in set.Beatmaps)
|
||||
{
|
||||
// These will all have a virtual track length of 1000, see WorkingBeatmap.GetVirtualTrack().
|
||||
b.Length = track_length - 1000;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
importedSet = beatmaps.GetAllUsableBeatmapSets().First();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStatusUpdateOnEnter()
|
||||
{
|
||||
@ -69,5 +108,42 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
AddAssert("close button present", () => roomScreen.ChildrenOfType<DangerousRoundedButton>().Any());
|
||||
AddUntilStep("wait for close button to disappear", () => !roomScreen.ChildrenOfType<DangerousRoundedButton>().Any());
|
||||
}
|
||||
|
||||
[TestCase(120_000, true)] // Definitely enough time.
|
||||
[TestCase(45_000, true)] // Enough time.
|
||||
[TestCase(35_000, false)] // Not enough time to complete beatmap after lenience.
|
||||
[TestCase(20_000, false)] // Not enough time.
|
||||
[TestCase(5_000, false)] // Not enough time to complete beatmap before lenience.
|
||||
[TestCase(37_500, true, 2)] // Enough time to complete beatmap after mods are applied.
|
||||
public void TestReadyButtonEnablementPeriod(int offsetMs, bool enabled, double rate = 1)
|
||||
{
|
||||
Room room = null!;
|
||||
PlaylistsRoomSubScreen roomScreen = null!;
|
||||
|
||||
AddStep("create room", () =>
|
||||
{
|
||||
RoomManager.AddRoom(room = new Room
|
||||
{
|
||||
Name = @"Test Room",
|
||||
Host = api.LocalUser.Value,
|
||||
Category = RoomCategory.Normal,
|
||||
StartDate = DateTimeOffset.Now,
|
||||
EndDate = DateTimeOffset.Now.AddMilliseconds(offsetMs),
|
||||
Playlist =
|
||||
[
|
||||
new PlaylistItem(importedSet!.Beatmaps[0])
|
||||
{
|
||||
RequiredMods = rate == 1
|
||||
? []
|
||||
: [new APIMod(new OsuModDoubleTime { SpeedChange = { Value = rate } })]
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
AddStep("push screen", () => LoadScreen(roomScreen = new PlaylistsRoomSubScreen(room)));
|
||||
AddUntilStep("wait for screen load", () => roomScreen.IsCurrentScreen());
|
||||
AddUntilStep("ready button enabled", () => roomScreen.ChildrenOfType<PlaylistsReadyButton>().SingleOrDefault()?.Enabled.Value, () => Is.EqualTo(enabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,16 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
new OsuMenuItem(@"Another nested option")
|
||||
{
|
||||
Items = new MenuItem[]
|
||||
{
|
||||
new OsuMenuItem(@"Sub-One"),
|
||||
new OsuMenuItem(@"Sub-Two"),
|
||||
new OsuMenuItem(@"Sub-Three"),
|
||||
}
|
||||
},
|
||||
new OsuMenuItem(@"Choose me please"),
|
||||
|
@ -11,16 +11,8 @@ namespace osu.Game.Graphics.Cursor
|
||||
[Cached(typeof(OsuContextMenuContainer))]
|
||||
public partial class OsuContextMenuContainer : ContextMenuContainer
|
||||
{
|
||||
[Cached]
|
||||
private OsuContextMenuSamples samples = new OsuContextMenuSamples();
|
||||
|
||||
private OsuContextMenu menu = null!;
|
||||
|
||||
public OsuContextMenuContainer()
|
||||
{
|
||||
AddInternal(samples);
|
||||
}
|
||||
|
||||
protected override Menu CreateMenu() => menu = new OsuContextMenu(true);
|
||||
|
||||
public void CloseMenu()
|
||||
|
@ -23,6 +23,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
DialogCancel,
|
||||
|
||||
[Description("dialog-ok")]
|
||||
DialogOk
|
||||
DialogOk,
|
||||
|
||||
[Description("menu-open")]
|
||||
MenuOpen,
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private const int fade_duration = 250;
|
||||
|
||||
[Resolved]
|
||||
private OsuContextMenuSamples samples { get; set; } = null!;
|
||||
private OsuMenuSamples menuSamples { get; set; } = null!;
|
||||
|
||||
// todo: this shouldn't be required after https://github.com/ppy/osu-framework/issues/4519 is fixed.
|
||||
private bool wasOpened;
|
||||
@ -47,15 +47,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override void AnimateOpen()
|
||||
{
|
||||
wasOpened = true;
|
||||
this.FadeIn(fade_duration, Easing.OutQuint);
|
||||
|
||||
if (playClickSample)
|
||||
samples.PlayClickSample();
|
||||
if (!playClickSample)
|
||||
return;
|
||||
|
||||
if (!wasOpened)
|
||||
samples.PlayOpenSample();
|
||||
|
||||
wasOpened = true;
|
||||
menuSamples?.PlayClickSample();
|
||||
menuSamples?.PlayOpenSample();
|
||||
}
|
||||
|
||||
protected override void AnimateClose()
|
||||
@ -63,7 +62,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
this.FadeOut(fade_duration, Easing.OutQuint);
|
||||
|
||||
if (wasOpened)
|
||||
samples.PlayCloseSample();
|
||||
menuSamples?.PlayCloseSample();
|
||||
|
||||
wasOpened = false;
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public partial class OsuContextMenuSamples : Component
|
||||
{
|
||||
private Sample sampleClick;
|
||||
private Sample sampleOpen;
|
||||
private Sample sampleClose;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
sampleClick = audio.Samples.Get($@"UI/{HoverSampleSet.Default.GetDescription()}-select");
|
||||
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
|
||||
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
|
||||
}
|
||||
|
||||
public void PlayClickSample() => Scheduler.AddOnce(playClickSample);
|
||||
private void playClickSample() => sampleClick.Play();
|
||||
|
||||
public void PlayOpenSample() => Scheduler.AddOnce(playOpenSample);
|
||||
private void playOpenSample() => sampleOpen.Play();
|
||||
|
||||
public void PlayCloseSample() => Scheduler.AddOnce(playCloseSample);
|
||||
private void playCloseSample() => sampleClose.Play();
|
||||
}
|
||||
}
|
@ -4,8 +4,6 @@
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -20,12 +18,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public partial class OsuMenu : Menu
|
||||
{
|
||||
private Sample sampleOpen;
|
||||
private Sample sampleClose;
|
||||
|
||||
// todo: this shouldn't be required after https://github.com/ppy/osu-framework/issues/4519 is fixed.
|
||||
private bool wasOpened;
|
||||
|
||||
[Resolved]
|
||||
private OsuMenuSamples menuSamples { get; set; } = null!;
|
||||
|
||||
public OsuMenu(Direction direction, bool topLevelMenu = false)
|
||||
: base(direction, topLevelMenu)
|
||||
{
|
||||
@ -33,13 +31,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
MaskingContainer.CornerRadius = 4;
|
||||
ItemsContainer.Padding = new MarginPadding(5);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
sampleOpen = audio.Samples.Get(@"UI/dropdown-open");
|
||||
sampleClose = audio.Samples.Get(@"UI/dropdown-close");
|
||||
OnSubmenuOpen += _ => { menuSamples?.PlaySubOpenSample(); };
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
@ -64,7 +57,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
protected override void AnimateOpen()
|
||||
{
|
||||
if (!TopLevelMenu && !wasOpened)
|
||||
sampleOpen?.Play();
|
||||
menuSamples?.PlayOpenSample();
|
||||
|
||||
this.FadeIn(300, Easing.OutQuint);
|
||||
wasOpened = true;
|
||||
@ -73,7 +66,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
protected override void AnimateClose()
|
||||
{
|
||||
if (!TopLevelMenu && wasOpened)
|
||||
sampleClose?.Play();
|
||||
menuSamples?.PlayCloseSample();
|
||||
|
||||
this.FadeOut(300, Easing.OutQuint);
|
||||
wasOpened = false;
|
||||
|
70
osu.Game/Graphics/UserInterface/OsuMenuSamples.cs
Normal file
70
osu.Game/Graphics/UserInterface/OsuMenuSamples.cs
Normal file
@ -0,0 +1,70 @@
|
||||
// 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.
|
||||
|
||||
#nullable disable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public partial class OsuMenuSamples : Component
|
||||
{
|
||||
private Sample sampleClick;
|
||||
private Sample sampleOpen;
|
||||
private Sample sampleSubOpen;
|
||||
private Sample sampleClose;
|
||||
|
||||
private bool triggerOpen;
|
||||
private bool triggerSubOpen;
|
||||
private bool triggerClose;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
sampleClick = audio.Samples.Get(@"UI/menu-open-select");
|
||||
sampleOpen = audio.Samples.Get(@"UI/menu-open");
|
||||
sampleSubOpen = audio.Samples.Get(@"UI/menu-sub-open");
|
||||
sampleClose = audio.Samples.Get(@"UI/menu-close");
|
||||
}
|
||||
|
||||
public void PlayClickSample()
|
||||
{
|
||||
Scheduler.AddOnce(playClickSample);
|
||||
}
|
||||
|
||||
public void PlayOpenSample()
|
||||
{
|
||||
triggerOpen = true;
|
||||
Scheduler.AddOnce(resolvePlayback);
|
||||
}
|
||||
|
||||
public void PlaySubOpenSample()
|
||||
{
|
||||
triggerSubOpen = true;
|
||||
Scheduler.AddOnce(resolvePlayback);
|
||||
}
|
||||
|
||||
public void PlayCloseSample()
|
||||
{
|
||||
triggerClose = true;
|
||||
Scheduler.AddOnce(resolvePlayback);
|
||||
}
|
||||
|
||||
private void playClickSample() => sampleClick.Play();
|
||||
|
||||
private void resolvePlayback()
|
||||
{
|
||||
if (triggerSubOpen)
|
||||
sampleSubOpen?.Play();
|
||||
else if (triggerOpen)
|
||||
sampleOpen?.Play();
|
||||
else if (triggerClose)
|
||||
sampleClose?.Play();
|
||||
|
||||
triggerOpen = triggerSubOpen = triggerClose = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -41,6 +41,7 @@ using osu.Game.Database;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.IO;
|
||||
@ -383,6 +384,10 @@ namespace osu.Game
|
||||
|
||||
GlobalActionContainer globalBindings;
|
||||
|
||||
OsuMenuSamples menuSamples;
|
||||
dependencies.Cache(menuSamples = new OsuMenuSamples());
|
||||
base.Content.Add(menuSamples);
|
||||
|
||||
base.Content.Add(SafeAreaContainer = new SafeAreaContainer
|
||||
{
|
||||
SafeAreaOverrideEdges = SafeAreaOverrideEdges,
|
||||
|
@ -99,7 +99,7 @@ namespace osu.Game.Screens.Edit.Components.Menus
|
||||
ForegroundColourHover = colourProvider.Content1;
|
||||
BackgroundColourHover = colourProvider.Background1;
|
||||
|
||||
AddInternal(hoverClickSounds = new HoverClickSounds());
|
||||
AddInternal(hoverClickSounds = new HoverClickSounds(HoverSampleSet.MenuOpen));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
@ -10,7 +11,9 @@ using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Screens.OnlinePlay.Components;
|
||||
using osu.Game.Utils;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
@ -19,6 +22,9 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> gameBeatmap { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
||||
|
||||
private readonly Room room;
|
||||
|
||||
public PlaylistsReadyButton(Room room)
|
||||
@ -63,14 +69,14 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Enabled.Value = hasRemainingAttempts && enoughTimeLeft;
|
||||
Enabled.Value = hasRemainingAttempts && enoughTimeLeft();
|
||||
}
|
||||
|
||||
public override LocalisableString TooltipText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!enoughTimeLeft)
|
||||
if (!enoughTimeLeft())
|
||||
return "No time left!";
|
||||
|
||||
if (!hasRemainingAttempts)
|
||||
@ -80,9 +86,17 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
}
|
||||
}
|
||||
|
||||
private bool enoughTimeLeft =>
|
||||
// This should probably consider the length of the currently selected item, rather than a constant 30 seconds.
|
||||
room.EndDate != null && DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(gameBeatmap.Value.Track.Length) < room.EndDate;
|
||||
private bool enoughTimeLeft()
|
||||
{
|
||||
double rate = ModUtils.CalculateRateWithMods(mods.Value);
|
||||
|
||||
// We want to avoid users not being able to submit scores if they chose to not skip,
|
||||
// so track length is chosen over playable length.
|
||||
double trackLength = Math.Round(gameBeatmap.Value.Track.Length / rate);
|
||||
|
||||
// Additional 30 second delay added to account for load and/or submit time.
|
||||
return room.EndDate != null && DateTimeOffset.UtcNow.AddSeconds(30).AddMilliseconds(trackLength) < room.EndDate;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
|
@ -401,7 +401,6 @@ namespace osu.Game.Screens.Select
|
||||
if (beatmap == null || bpmLabelContainer == null)
|
||||
return;
|
||||
|
||||
// this doesn't consider mods which apply variable rates, yet.
|
||||
double rate = ModUtils.CalculateRateWithMods(mods.Value);
|
||||
|
||||
int bpmMax = FormatUtils.RoundBPM(beatmap.ControlPointInfo.BPMMaximum, rate);
|
||||
|
@ -286,6 +286,7 @@ namespace osu.Game.Utils
|
||||
{
|
||||
double rate = 1;
|
||||
|
||||
// TODO: This doesn't consider mods which apply variable rates, yet.
|
||||
foreach (var mod in mods.OfType<IApplicableToRate>())
|
||||
rate = mod.ApplyToRate(0, rate);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user